/**
  * load roles to item
  *
  * @param User $item
  */
 private function loadAuthDrivers(&$item)
 {
     // clear roles
     $item->deleteAllAuthDrivers();
     // set roles to item
     foreach ($this->getAuthDrivers($item->id) as $authDriver => $authId) {
         $item->addAuthDriver($authDriver, $authId);
     }
 }
Ejemplo n.º 2
0
 /**
  * Update roles
  *
  * @param User        $user
  * @param Models\User $adUser
  */
 protected function updateRole(User &$user, Models\User $adUser)
 {
     $memberOf = [];
     foreach ($adUser->getMemberOfNames() as $group) {
         $memberOf[] = \Adldap\Classes\Utilities::unescape($group);
     }
     foreach ($this->group2Role as $group => $role) {
         if (in_array($group, $memberOf, true)) {
             if ($this->roleExists($role)) {
                 $user->addRole($role);
             }
         }
     }
 }