attributes = array($ldap->getLDAPParam('cn'), $ldap->getLDAPParam('mail'), $ldap->getLDAPParam('uid'),$ldap->getLDAPParam('sn'), $ldap->getLDAPParam('givenName')); return $this->attributes; } /** * Do all the synchronization between an ldap result and a Tuleap user. * * This method returns if it modified the user or not. This is usefull during * batch process in order to limit computing. * * @param PFUser $user User * @param LDAPResult $lr Ldap result * * @return Boolean True if the method modified the user object */ public function sync(PFUser $user, LDAPResult $lr) { $modified = false; $realname = $this->getCommonName($lr); if (($realname !== null) && ($user->getRealName() != substr($realname, 0, 32))) { $user->setRealName($realname); $modified = true; } $ldapEmail = $lr->getEmail(); if (($ldapEmail !== null) && ($user->getEmail() != $ldapEmail)) { $user->setEmail($ldapEmail); $modified = true; } $userEmail = $user->getEmail(); if ($userEmail !== null) { if ($user->getStatus() != PFUser::STATUS_ACTIVE) { if (preg_match("/.ext@orange.com/i", $userEmail)) { $user->setStatus(PFUser::STATUS_RESTRICTED); if (isset($GLOBALS['Response'])) { $GLOBALS['Response']->addFeedback('info', "Your account is restricted to projects your are member of"); } $modified = true; } else { if (preg_match("/@orange.com/i", $userEmail)) { $user->setStatus(PFUser::STATUS_ACTIVE); $modified = true; } else { $user->setStatus(PFUser::STATUS_RESTRICTED); if (isset($GLOBALS['Response'])) { $GLOBALS['Response']->addFeedback('info', "Your account is restricted to projects your are member of"); } $modified = true; } } } } else { if ($user->getStatus() != PFUser::STATUS_ACTIVE) { $user->setStatus(PFUser::STATUS_RESTRICTED); if (isset($GLOBALS['Response'])) { $GLOBALS['Response']->addFeedback('info', "Your account is restricted to projects your are member of"); } $modified = true; } } return $modified; } public function getCommonName(LDAPResult $lr) { return $lr->get('givenName') . ' ' . $lr->get('sn'); } } ?>