/** * @brief returns a User object by it's DN or ownCloud username * @param string the DN or username of the user * @return \OCA\user_ldap\lib\User | null */ public function get($id) { $this->checkAccess(); if (isset($this->users['byDN'][$id])) { return $this->users['byDN'][$id]; } else { if (isset($this->users['byUid'][$id])) { return $this->users['byUid'][$id]; } } if (!$this->access->stringResemblesDN($id)) { //most likely a uid $dn = $this->access->username2dn($id); if ($dn !== false) { return $this->createAndCache($dn, $id); } } else { //so it's a DN $uid = $this->access->dn2username($id); if ($uid !== false) { return $this->createAndCache($id, $uid); } } //either funny uid or invalid. Assume funny to be on the safe side. $dn = $this->access->username2dn($id); if ($dn !== false) { return $this->createAndCache($dn, $id); } return null; }
/** * @brief returns a User object by it's DN or ownCloud username * @param string the DN or username of the user * @return \OCA\user_ldap\lib\User | null */ public function get($id) { $this->checkAccess(); if (isset($this->users['byDN'][$id])) { return $this->users['byDN'][$id]; } else { if (isset($this->users['byUid'][$id])) { return $this->users['byUid'][$id]; } } if (strpos(mb_strtolower($id, 'UTF-8'), 'dc=') === false && strpos(mb_strtolower($id, 'UTF-8'), 'uid=') === false) { //most likely a uid $dn = $this->access->username2dn($id); if ($dn !== false) { return $this->createAndCache($dn, $id); } } else { //so it's a DN $uid = $this->access->dn2username($id); if ($uid !== false) { return $this->createAndCache($id, $uid); } } //either funny uid or invalid. Assume funny to be on the safe side. $dn = $this->access->username2dn($id); if ($dn !== false) { return $this->createAndCache($dn, $id); } return null; }
/** * @brief returns a User object by it's DN or ownCloud username * @param string the DN or username of the user * @return \OCA\user_ldap\lib\user\User|\OCA\user_ldap\lib\user\OfflineUser|null * @throws \Exception when connection could not be established */ public function get($id) { $this->checkAccess(); if(isset($this->users['byDN'][$id])) { return $this->users['byDN'][$id]; } else if(isset($this->users['byUid'][$id])) { return $this->users['byUid'][$id]; } if($this->access->stringResemblesDN($id) ) { $uid = $this->access->dn2username($id); if($uid !== false) { return $this->createAndCache($id, $uid); } } return $this->createInstancyByUserName($id); }
/** * @brief returns a User object by it's DN or ownCloud username * @param string the DN or username of the user * @return \OCA\user_ldap\lib\user\User|\OCA\user_ldap\lib\user\OfflineUser|null */ public function get($id) { $this->checkAccess(); if (isset($this->users['byDN'][$id])) { return $this->users['byDN'][$id]; } else { if (isset($this->users['byUid'][$id])) { return $this->users['byUid'][$id]; } } if ($this->access->stringResemblesDN($id)) { $uid = $this->access->dn2username($id); if ($uid !== false) { return $this->createAndCache($id, $uid); } } try { $user = $this->createInstancyByUserName($id); return $user; } catch (\Exception $e) { return null; } }