/** * Add (by name) new users into a user group. * * @param Array $userList List of user identifier (e.g. ldap login) * * @return void */ public function addListOfUsersToGroup($userList) { $ldapUserManager = new LDAP_UserManager($this->getLdap(), LDAP_UserSync::instance()); $userIds = $ldapUserManager->getUserIdsFromUserList($userList); foreach ($userIds as $userId) { $this->addUserToGroup($this->id, $userId); } }
/** * Instanciate the right LDAP_UserSync object * * Site can define its own implementation in /etc/codendi/plugins/ldap/site-content/en_US/synchronize_user.txt * * @return LDAP_UserSync */ public static function instance() { if (!isset(self::$instance)) { $syncClass = __CLASS__; // Allows site defined user update include_once $GLOBALS['Language']->getContent('synchronize_user', 'en_US', 'ldap'); self::$instance = new $syncClass(); } return self::$instance; }
/** * Wrapper for LDAP_UserManager * * @return LDAP_UserManager */ protected function getLDAPUserManager() { if ($this->ldapUserManager === null) { $this->ldapUserManager = new LDAP_UserManager($this->ldap, LDAP_UserSync::instance()); } return $this->ldapUserManager; }
protected function getLdapUserSync() { return LDAP_UserSync::instance(); }
/** * Synchronize user account with LDAP informations * * @param PFUser $user * @param LDAPResult $lr * @param String $password * @return Boolean */ function synchronizeUser(PFUser $user, LDAPResult $lr, $password) { $user->setPassword($password); $sync = LDAP_UserSync::instance(); $sync->sync($user, $lr); // Perform DB update $userUpdated = $this->getUserManager()->updateDb($user); $ldapUpdated = true; $user_id = $this->getLdapLoginFromUserIds(array($user->getId()))->getRow(); if ($user_id['ldap_uid'] != $lr->getLogin()) { $ldapUpdated = $this->updateLdapUid($user, $lr->getLogin()); $this->triggerRenameOfUsers(); } return $userUpdated || $ldapUpdated; }
/** * Hook * * IN $params['codendiUserOnly'] * IN $params['limit'] * IN $params['searchToken'] * IN $params['validEmail'] * OUT $params['userList'] * OUT $params['pluginAnswered'] * * @param Array $params * * @return void */ function ajax_search_user($params) { if ($this->isLDAPUserManagementEnabled() && !$params['codendiUserOnly']) { $params['pluginAnswered'] = true; $validEmail = isset($params['validEmail']) ? $params['validEmail'] : false; $ldap = $this->getLdap(); $lri = $ldap->searchUserAsYouType($params['searchToken'], $params['limit'], $validEmail); $sync = LDAP_UserSync::instance(); foreach ($lri as $lr) { if ($lr->exist() && $lr->valid()) { $params['userList'][] = $sync->getCommonName($lr) . ' (' . $lr->getLogin() . ')'; } } if ($ldap->getErrno() == LDAP::ERR_SIZELIMIT) { $params['userList'][] = "<strong>...</strong>"; } } }
/** * Get the Codendi user id of the people in given LDAP group * * This method takes an LDAP group Distinguish Name * - Fetch all the members of the group * - Creates their Codendi account if it doesn't exist * - Return the Codendi id of people * * @param String $groupDn LDAP DN of the group. * * @return Array */ public function getLdapGroupMembersIds($groupDn) { $ldapUserManager = new LDAP_UserManager($this->getLdap(), LDAP_UserSync::instance()); $ldapGroupMembers = $this->getLdapGroupMembers($groupDn); $ldapGroupUserIds = $ldapUserManager->getUserIdsForLdapUser($ldapGroupMembers); return $ldapGroupUserIds; }