Пример #1
0
 /**
  * Coping with AD not returning the primary group.
  *
  * http://support.microsoft.com/?kbid=321360.
  *
  * @param string $group The name of the group
  * @param string $user  The username of the user
  *
  * @return bool
  */
 public function getPrimaryGroup($group, $user)
 {
     $group = $this->find($group);
     $user = $this->getAdldap()->users()->find($user);
     if ($group instanceof Group && $user instanceof User) {
         $sid = Utilities::binarySidToText($group->getSid());
         $result = $this->adldap->search()->where(ActiveDirectory::OBJECT_SID, '=', $sid)->first();
         if ($result instanceof Entry) {
             return $result->getDn();
         }
     }
     return false;
 }
Пример #2
0
 /**
  * @param string    $username
  * @param string    $password
  * @param null|User $user
  *
  * @return boolean
  */
 public function authenticate($username, $password, &$user)
 {
     if ($this->ad === null) {
         $this->ad = new Adldap($this->adConfig);
     }
     $authSuccess = false;
     if ($this->ad->authenticate($username, $password, true)) {
         $adUser = $this->ad->users()->find($username);
         $sid = \Adldap\Classes\Utilities::binarySidToText($adUser->getObjectSID());
         if ($user === null and $this->hasAutoAddUser($adUser)) {
             $user = $this->createUserFromAd($adUser);
         }
         if ($user !== null) {
             if ($this->autoUpdateRole) {
                 $this->updateRole($user, $adUser);
             }
             $user->addAuthDriver($this->getName(), $sid);
             $authSuccess = true;
         }
     }
     return $authSuccess;
 }