Exemplo 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);
 }
Exemplo n.º 2
0
 /**
  * Retrieves universally unique ID (UUID) of current user.
  *
  * @return string UUID of user e.g. for storing related data in a database
  */
 public function getUUID()
 {
     $uuid = $this->getProperty('uuid');
     if (strlen(trim($uuid)) < 36) {
         $uuid = uuid::createRandom();
         $this->setProperty('uuid', $uuid);
     }
     return $uuid;
 }