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
Archivo: user.php Proyecto: 0x17de/core
 /**
  * fetches the quota from LDAP and stores it as ownCloud user value
  * @param string $valueFromLDAP the quota attribute's value can be passed,
  * to save the readAttribute request
  * @return null
  */
 public function updateQuota($valueFromLDAP = null)
 {
     if ($this->wasRefreshed('quota')) {
         return;
     }
     //can be null
     $quotaDefault = $this->connection->ldapQuotaDefault;
     $quota = !is_null($valueFromLDAP) ? $valueFromLDAP : $quotaDefault !== '' ? $quotaDefault : null;
     if (is_null($valueFromLDAP)) {
         $quotaAttribute = $this->connection->ldapQuotaAttribute;
         if (!empty($quotaAttribute)) {
             $aQuota = $this->access->readAttribute($this->dn, $quotaAttribute);
             if ($aQuota && count($aQuota) > 0) {
                 $quota = $aQuota[0];
             }
         }
     }
     if (!is_null($quota)) {
         $this->config->setUserValue($this->uid, 'files', 'quota', $quota);
     }
 }
Ejemplo n.º 5
0
 /**
  * @brief fetches the quota from LDAP and stores it as ownCloud user value
  * @return null
  */
 public function updateQuota()
 {
     if ($this->wasRefreshed('quota')) {
         return;
     }
     $quota = null;
     $quotaDefault = $this->connection->ldapQuotaDefault;
     $quotaAttribute = $this->connection->ldapQuotaAttribute;
     if (!empty($quotaDefault)) {
         $quota = $quotaDefault;
     }
     if (!empty($quotaAttribute)) {
         $aQuota = $this->access->readAttribute($this->dn, $quotaAttribute);
         if ($aQuota && count($aQuota) > 0) {
             $quota = $aQuota[0];
         }
     }
     if (!is_null($quota)) {
         $this->config->setUserValue($this->uid, 'files', 'quota', $quota);
     }
 }
Ejemplo n.º 6
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;
     }
 }