/** * processes results from LDAP for attributes as returned by getAttributesToRead() * @param array $ldapEntry the user entry as retrieved from LDAP */ public function processAttributes($ldapEntry) { $this->markRefreshTime(); //Quota $attr = strtolower($this->connection->ldapQuotaAttribute); if (isset($ldapEntry[$attr])) { $this->updateQuota($ldapEntry[$attr][0]); } unset($attr); //Email $attr = strtolower($this->connection->ldapEmailAttribute); if (isset($ldapEntry[$attr])) { $this->updateEmail($ldapEntry[$attr][0]); } unset($attr); //displayName $attr = strtolower($this->connection->ldapUserDisplayName); if (isset($ldapEntry[$attr])) { $displayName = $ldapEntry[$attr][0]; if (!empty($displayName)) { $this->storeDisplayName($displayName); $this->access->cacheUserDisplayName($this->getUsername(), $displayName); } } unset($attr); // LDAP Username, needed for s2s sharing if (isset($ldapEntry['uid'])) { $this->storeLDAPUserName($ldapEntry['uid'][0]); } else { if (isset($ldapEntry['samaccountname'])) { $this->storeLDAPUserName($ldapEntry['samaccountname'][0]); } } //homePath if (strpos($this->connection->homeFolderNamingRule, 'attr:') === 0) { $attr = strtolower(substr($this->connection->homeFolderNamingRule, strlen('attr:'))); if (isset($ldapEntry[$attr])) { $this->access->cacheUserHome($this->getUsername(), $this->getHomePath($ldapEntry[$attr][0])); } } //memberOf groups $cacheKey = 'getMemberOf' . $this->getUsername(); $groups = false; if (isset($ldapEntry['memberof'])) { $groups = $ldapEntry['memberof']; } $this->connection->writeToCache($cacheKey, $groups); //Avatar $attrs = array('jpegphoto', 'thumbnailphoto'); foreach ($attrs as $attr) { if (isset($ldapEntry[$attr])) { $this->avatarImage = $ldapEntry[$attr][0]; $this->updateAvatar(); break; } } }
/** * processes results from LDAP for attributes as returned by getAttributesToRead() * @param array $ldapEntry the user entry as retrieved from LDAP */ public function processAttributes($ldapEntry) { $this->markRefreshTime(); //Quota $attr = strtolower($this->connection->ldapQuotaAttribute); if (isset($ldapEntry[$attr])) { $this->updateQuota($ldapEntry[$attr][0]); } unset($attr); //Email $attr = strtolower($this->connection->ldapEmailAttribute); if (isset($ldapEntry[$attr])) { $this->updateEmail($ldapEntry[$attr][0]); } unset($attr); //displayName $displayName = $displayName2 = ''; $attr = strtolower($this->connection->ldapUserDisplayName); if (isset($ldapEntry[$attr])) { $displayName = $ldapEntry[$attr][0]; } $attr = strtolower($this->connection->ldapUserDisplayName2); if (isset($ldapEntry[$attr])) { $displayName2 = $ldapEntry[$attr][0]; } if (!empty($displayName)) { $this->composeAndStoreDisplayName($displayName); $this->access->cacheUserDisplayName($this->getUsername(), $displayName, $displayName2); } unset($attr); // LDAP Username, needed for s2s sharing if (isset($ldapEntry['uid'])) { $this->storeLDAPUserName($ldapEntry['uid'][0]); } else { if (isset($ldapEntry['samaccountname'])) { $this->storeLDAPUserName($ldapEntry['samaccountname'][0]); } } //homePath if (strpos($this->connection->homeFolderNamingRule, 'attr:') === 0) { $attr = strtolower(substr($this->connection->homeFolderNamingRule, strlen('attr:'))); if (isset($ldapEntry[$attr])) { $this->access->cacheUserHome($this->getUsername(), $this->getHomePath($ldapEntry[$attr][0])); } } //memberOf groups $cacheKey = 'getMemberOf' . $this->getUsername(); $groups = false; if (isset($ldapEntry['memberof'])) { $groups = $ldapEntry['memberof']; } $this->connection->writeToCache($cacheKey, $groups); //Avatar $attrs = array('jpegphoto', 'thumbnailphoto'); foreach ($attrs as $attr) { if (isset($ldapEntry[$attr])) { $this->avatarImage = $ldapEntry[$attr][0]; // the call to the method that saves the avatar in the file // system must be postponed after the login. It is to ensure // external mounts are mounted properly (e.g. with login // credentials from the session). \OCP\Util::connectHook('OC_User', 'post_login', $this, 'updateAvatarPostLogin'); break; } } }