3 declare(strict_types=1);
    48         $this->log = $DIC->logger()->auth();
    49         $this->rbacreview = $DIC->rbac()->review();
    50         $this->ilObjDataCache = $DIC[
'ilObjDataCache'];
    60         if (is_object(self::$instance)) {
    61             return self::$instance;
    74     public function getInfoStrings(
int $a_obj_id, 
bool $a_check_type = 
false): array
    76         if (!$this->active_servers) {
    81             if (isset($this->mapping_info_strict[$a_obj_id]) && is_array($this->mapping_info_strict[$a_obj_id])) {
    82                 return $this->mapping_info_strict[$a_obj_id];
    84         } elseif (isset($this->mapping_info[$a_obj_id]) && is_array($this->mapping_info[$a_obj_id])) {
    85             return $this->mapping_info[$a_obj_id];
    97     public function assign($a_role_id, $a_usr_id): bool
   100         if (!$this->active_servers) {
   108             $this->log->write(
'LDAP assign: User ID: ' . $a_usr_id . 
' has no LDAP account');
   111         $this->log->write(
'LDAP assign: User ID: ' . $a_usr_id . 
' Role Id: ' . $a_role_id);
   128         if (!$this->active_servers) {
   136         foreach ($this->rbacreview->assignedUsers($a_role_id) as $usr_id) {
   137             $this->
deassign($a_role_id, $usr_id);
   148     public function deassign($a_role_id, $a_usr_id): bool
   151         if (!$this->active_servers) {
   160         $this->log->write(
'LDAP deassign: User ID: ' . $a_usr_id . 
' Role Id: ' . $a_role_id);
   173         if (!$this->active_servers) {
   177         foreach ($this->mappings as $role_id) {
   178             $this->
deassign($role_id, $a_usr_id);
   191         if (!count($server_ids)) {
   196         $this->active_servers = 
true;
   198         $this->mappings = [];
   199         foreach ($server_ids as $server_id) {
   200             $this->servers[$server_id] = 
new ilLDAPServer($server_id);
   201             $this->mappings = ilLDAPRoleGroupMappingSettings::_getAllActiveMappings();
   203         $this->mapping_info = [];
   204         $this->mapping_info_strict = [];
   205         foreach ($this->mappings as $mapping) {
   206             foreach ($mapping as 
$data) {
   207                 if ($data[
'info'] !== 
'' && $data[
'object_id']) {
   208                     $this->mapping_info[$data[
'object_id']][] = $data[
'info'];
   211                     $this->mapping_info_strict[$data[
'object_id']][] = $data[
'info'];
   223         if (!is_string($a_role_id) || !is_int($a_role_id)) {
   227         return array_key_exists($a_role_id, $this->mappings);
   235         return array_key_exists($a_usr_id, $this->users);
   247         foreach ($this->mappings[$a_role_id] as 
$data) {
   250                     $external_account = $this->
readDN($a_usr_id, $data[
'server_id']);
   252                     $external_account = $this->users[$a_usr_id];
   256                 #if($this->isMember($external_account,$data))   258                 #       $this->log->write("LDAP assign: User already assigned to group '".$data['dn']."'");   264                     $query_obj->modAdd($data[
'dn'], array($data[
'member'] => $external_account));
   265                     $this->log->write(
'LDAP assign: Assigned ' . $external_account . 
' to group ' . $data[
'dn']);
   268                 $this->log->write($exc->getMessage());
   284         foreach ($this->mappings[$a_role_id] as 
$data) {
   287                     $external_account = $this->
readDN($a_usr_id, $data[
'server_id']);
   289                     $external_account = $this->users[$a_usr_id];
   294                     $this->log->write(
'LDAP deassign: User is still assigned to role "' . $role_id . 
'".');
   306                 $query_obj->modDelete($data[
'dn'], array($data[
'member'] => $external_account));
   307                 $this->log->write(
'LDAP deassign: Deassigned ' . $external_account . 
' from group ' . $data[
'dn']);
   310                 if (is_array($this->mapping_members[$data[
'mapping_id']])) {
   311                     $key = array_search($external_account, $this->mapping_members[$data[
'mapping_id']], 
true);
   313                         unset($this->mapping_members[$data[
'mapping_id']]);
   317                 $this->log->write($exc->getMessage());
   332         foreach ($this->mappings as $role_id => $tmp_data) {
   333             foreach ($tmp_data as 
$data) {
   334                 if ($role_id === $a_role_id) {
   337                 if ($data[
'server_id'] !== $a_data[
'server_id']) {
   340                 if ($data[
'dn'] !== $a_data[
'dn']) {
   343                 if ($this->rbacreview->isAssigned($a_usr_id, $role_id)) {
   344                     return $this->ilObjDataCache->lookupTitle((
int) $role_id);
   358     private function readDN(
int $a_usr_id, 
int $a_server_id)
   360         if ($this->user_dns === null) {
   361             $this->user_dns = [];
   363         if (isset($this->user_dns[$a_usr_id])) {
   364             return $this->user_dns[$a_usr_id];
   367         $external_account = $this->users[$a_usr_id];
   369         $server = $this->servers[$a_server_id];
   372         if ($search_base = 
$server->getSearchBase()) {
   375         $search_base .= 
$server->getBaseDN();
   378         if (
$server->isMembershipOptional() && 
$server->getGroupUserFilter()) {
   379             $userFilter = 
$server->getGroupUserFilter();
   381             $userFilter = 
$server->getFilter();
   391         $res = $query_obj->query($search_base, $filter, 
$server->getUserScope(), array(
'dn'));
   393         if (!$res->numRows()) {
   396         if ($res->numRows() > 1) {
   397             throw new ilLDAPQueryException(__METHOD__ . 
' found multiple distinguished name for: ' . $external_account);
   401         $this->user_dns[$a_usr_id] = 
$data[
'dn'];
   402         return $this->user_dns[$a_usr_id];
   412         if (array_key_exists($a_server_id, $this->query) &&
   413             array_key_exists($a_url, $this->query[$a_server_id]) &&
   414             is_object($this->query[$a_server_id][$a_url])) {
   415             return $this->query[$a_server_id][$a_url];
   417         $tmp_query = 
new ilLDAPQuery($this->servers[$a_server_id], $a_url);
   420         return $this->query[$a_server_id][$a_url] = $tmp_query;
 
checkOtherMembership(int $a_usr_id, int $a_role_id, array $a_data)
Check other membership. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getLDAPQueryInstance($a_server_id, $a_url)
Get LDAPQueryInstance. 
 
initServers()
Check if there is any active server with. 
 
__construct()
Singleton contructor. 
 
array $mapping_info_strict
 
deassign($a_role_id, $a_usr_id)
This method is typically called from class RbacAdmin::deassignUser() It checks if there is a role map...
 
isHandledRole($a_role_id)
 
static _getInstance()
Get singleton instance of this class. 
 
assign($a_role_id, $a_usr_id)
This method is typically called from class RbacAdmin::assignUser() It checks if there is a role mappi...
 
static _getExternalAccountsByAuthMode(string $a_auth_mode, bool $a_read_auth_default=false)
Get list of external account by authentication method Note: If login == ext_account for two user with...
 
static ilLDAPRoleGroupMapping $instance
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
deleteUser($a_usr_id)
Delete user => deassign from all ldap groups. 
 
getInfoStrings(int $a_obj_id, bool $a_check_type=false)
Get info string for object If check info type is enabled this function will check if the info string ...
 
assignToGroup($a_role_id, $a_usr_id)
Assign user to group. 
 
isHandledUser($a_usr_id)
Check if user is ldap user. 
 
deleteRole(int $a_role_id)
Delete role. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
deassignFromGroup($a_role_id, $a_usr_id)
Deassign user from group. 
 
readDN(int $a_usr_id, int $a_server_id)
Read DN of user. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
ilObjectDataCache $ilObjDataCache
 
static _getRoleSyncServerIds()
Check whether there if there is an active server with option role_sync_active.