24 include_once(
'Services/LDAP/classes/class.ilLDAPServer.php');
66 if (is_object(self::$instance)) {
67 return self::$instance;
83 if (!$this->active_servers) {
87 if (isset($this->mapping_info_strict[$a_obj_id]) and is_array($this->mapping_info_strict[$a_obj_id])) {
88 return $this->mapping_info_strict[$a_obj_id];
91 if (isset($this->mapping_info[$a_obj_id]) and is_array($this->mapping_info[$a_obj_id])) {
92 return $this->mapping_info[$a_obj_id];
108 public function assign($a_role_id, $a_usr_id)
111 if (!$this->active_servers) {
119 $this->log->write(
'LDAP assign: User ID: ' . $a_usr_id .
' has no LDAP account');
122 $this->log->write(
'LDAP assign: User ID: ' . $a_usr_id .
' Role Id: ' . $a_role_id);
142 if (!$this->active_servers) {
150 foreach ($rbacreview->assignedUsers($a_role_id) as $usr_id) {
151 $this->
deassign($a_role_id, $usr_id);
169 if (!$this->active_servers) {
178 $this->log->write(
'LDAP deassign: User ID: ' . $a_usr_id .
' Role Id: ' . $a_role_id);
192 foreach ($this->mappings as $role_id =>
$data) {
193 $this->
deassign($role_id, $a_usr_id);
210 if (!count($server_ids)) {
215 include_once(
'Services/LDAP/classes/class.ilLDAPRoleGroupMappingSettings.php');
217 $this->active_servers =
true;
218 $this->mappings =
array();
219 foreach ($server_ids as $server_id) {
220 $this->servers[$server_id] =
new ilLDAPServer($server_id);
223 $this->mapping_info =
array();
224 $this->mapping_info_strict =
array();
225 foreach ($this->mappings as $mapping) {
227 if (strlen(
$data[
'info']) and
$data[
'object_id']) {
228 $this->mapping_info[$data[
'object_id']][] = $data[
'info'];
231 $this->mapping_info_strict[$data[
'object_id']][] = $data[
'info'];
250 return array_key_exists($a_role_id, $this->mappings);
260 return array_key_exists($a_usr_id, $this->users);
273 foreach ($this->mappings[$a_role_id] as
$data) {
276 $external_account = $this->
readDN($a_usr_id, $data[
'server_id']);
278 $external_account = $this->users[$a_usr_id];
282 #if($this->isMember($external_account,$data)) 284 # $this->log->write("LDAP assign: User already assigned to group '".$data['dn']."'"); 290 $query_obj->modAdd($data[
'dn'],
array($data[
'member'] => $external_account));
291 $this->log->write(
'LDAP assign: Assigned ' . $external_account .
' to group ' . $data[
'dn']);
294 $this->log->write($exc->getMessage());
311 foreach ($this->mappings[$a_role_id] as
$data) {
314 $external_account = $this->
readDN($a_usr_id, $data[
'server_id']);
316 $external_account = $this->users[$a_usr_id];
321 $this->log->write(
'LDAP deassign: User is still assigned to role "' . $role_id .
'".');
333 $query_obj->modDelete($data[
'dn'],
array($data[
'member'] => $external_account));
334 $this->log->write(
'LDAP deassign: Deassigned ' . $external_account .
' from group ' . $data[
'dn']);
337 if (is_array($this->mapping_members[$data[
'mapping_id']])) {
338 $key = array_search($external_account, $this->mapping_members[$data[
'mapping_id']]);
340 unset($this->mapping_members[$data[
'mapping_id']]);
344 $this->log->write($exc->getMessage());
359 if (!isset($this->mapping_members[
"$data[mapping_id]"])) {
362 $server = $this->servers[
"$data[server_id]"];
366 $res = $query_obj->query(
379 #var_dump("<pre>",$a_uid,$this->mapping_members,"</pre>"); 382 if (in_array($a_uid, $this->mapping_members[
"$data[mapping_id]"])) {
397 global $rbacreview,$ilObjDataCache;
399 foreach ($this->mappings as $role_id => $tmp_data) {
400 foreach ($tmp_data as
$data) {
401 if ($role_id == $a_role_id) {
404 if ($data[
'server_id'] != $a_data[
'server_id']) {
407 if ($data[
'dn'] != $a_data[
'dn']) {
410 if ($rbacreview->isAssigned($a_usr_id, $role_id)) {
411 return $ilObjDataCache->lookupTitle($role_id);
426 $this->mapping_members[$a_mapping_id] =
array();
427 foreach ($a_data as $field => $value) {
428 if (strtolower($field) ==
'dn') {
432 if (!is_array($value)) {
433 $this->mapping_members[$a_mapping_id][] = $value;
436 foreach ($value as $external_account) {
437 $this->mapping_members[$a_mapping_id][] = $external_account;
451 private function readDN($a_usr_id, $a_server_id)
453 if (isset($this->user_dns[$a_usr_id])) {
454 return $this->user_dns[$a_usr_id];
457 $external_account = $this->users[$a_usr_id];
460 $server = $this->servers[$a_server_id];
463 if ($search_base =
$server->getSearchBase()) {
466 $search_base .=
$server->getBaseDN();
469 if (
$server->isMembershipOptional() and
$server->getGroupUserFilter()) {
470 $userFilter =
$server->getGroupUserFilter();
472 $userFilter =
$server->getFilter();
482 $res = $query_obj->query($search_base, $filter,
$server->getUserScope(),
array(
'dn'));
484 if (!$res->numRows()) {
485 include_once(
'Services/LDAP/classes/class.ilLDAPQueryException.php');
488 if ($res->numRows() > 1) {
489 include_once(
'Services/LDAP/classes/class.ilLDAPQueryException.php');
490 throw new ilLDAPQueryException(__METHOD__ .
' found multiple distinguished name for: ' . $external_account);
494 return $this->user_dns[$a_usr_id] =
$data[
'dn'];
509 include_once
'Services/LDAP/classes/class.ilLDAPQuery.php';
511 if (array_key_exists($a_server_id, $this->query) and
512 array_key_exists($a_url, $this->query[$a_server_id]) and
513 is_object($this->query[$a_server_id][$a_url])) {
514 return $this->query[$a_server_id][$a_url];
517 $tmp_query =
new ilLDAPQuery($this->servers[$a_server_id], $a_url);
522 return $this->query[$a_server_id][$a_url] = $tmp_query;
getLDAPQueryInstance($a_server_id, $a_url)
Get LDAPQueryInstance.
deleteRole($a_role_id)
Delete role.
initServers()
Check if there is any active server with.
checkOtherMembership($a_usr_id, $a_role_id, $a_data)
Check other membership.
static _getExternalAccountsByAuthMode($a_auth_mode, $a_read_auth_default=false)
Get list of external account by authentication method Note: If login == ext_account for two user with...
__construct()
Singleton contructor.
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)
Check if a role is handled or not.
readDN($a_usr_id, $a_server_id)
Read DN of user.
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...
foreach($_POST as $key=> $value) $res
isMember($a_uid, $data)
Check if user is member.
deleteUser($a_usr_id)
Delete user => deassign from all ldap groups.
assignToGroup($a_role_id, $a_usr_id)
Assign user to group.
storeMembers($a_mapping_id, $a_data)
Store Members.
static _getAllActiveMappings()
isHandledUser($a_usr_id)
Check if user is ldap user.
Create styles array
The data for the language used.
getInfoStrings($a_obj_id, $a_check_type=false)
Get info string for object If check info type is enabled this function will check if the info string ...
deassignFromGroup($a_role_id, $a_usr_id)
Deassign user from group.
static _getRoleSyncServerIds()
Check whether there if there is an active server with option role_sync_active.