Ejemplo n.º 1
0
 /**
  * @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;
 }
Ejemplo n.º 2
0
 /**
  * @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;
 }
Ejemplo n.º 3
0
	/**
	 * @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);
	}
Ejemplo n.º 4
0
 /**
  * @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;
     }
 }