Esempio n. 1
0
 protected function search($userIdOrLoginName)
 {
     if (mail::isValidAddress($userIdOrLoginName)) {
         $match = $this->server->searchSub(sprintf($this->setup->read('searchByMail', '(mailPublic=%s)'), $userIdOrLoginName), $this->setup->basedn);
     } else {
         if (strpos($userIdOrLoginName, '=') !== false) {
             $match = $this->server->searchBase($userIdOrLoginName);
         } else {
             if (ctype_digit($userIdOrLoginName)) {
                 $match = $this->server->searchSub(sprintf($this->setup->read('searchById', '(uidNumber=%d)'), $userIdOrLoginName), $this->setup->basedn);
             } else {
                 if (uuid::isValid($userIdOrLoginName)) {
                     $match = $this->server->searchSub(sprintf($this->setup->read('searchByUuid', '(entryUUID=%s)'), $userIdOrLoginName), $this->setup->basedn);
                 } else {
                     $match = $this->server->searchSub(sprintf($this->setup->read('searchByLogin', '(uid=%s)'), $userIdOrLoginName), $this->setup->basedn);
                 }
             }
         }
     }
     if ($match->current()) {
         $this->userDN = $match->current()->getDN();
         return $this;
     }
     throw new unauthorized_exception('no such user', unauthorized_exception::USER_NOT_FOUND);
 }