25 define(
'IL_LDAP_BIND_ANONYMOUS',0);
26 define(
'IL_LDAP_BIND_USER',1);
28 define(
'IL_LDAP_SCOPE_SUB',0);
29 define(
'IL_LDAP_SCOPE_ONE',1);
30 define(
'IL_LDAP_SCOPE_BASE',2);
58 $this->server_id = $a_server_id;
72 $query =
"SELECT server_id FROM ldap_server_settings ".
75 $res = $ilDB->query($query);
78 $server_ids[] = $row->server_id;
80 return $server_ids ? $server_ids : array();
92 $query =
"SELECT server_id FROM ldap_server_settings ".
94 "AND sync_per_cron = 1 ".
97 $res = $ilDB->query($query);
100 $server_ids[] = $row->server_id;
102 return $server_ids ? $server_ids : array();
116 $query =
"SELECT server_id FROM ldap_server_settings ".
118 "AND role_sync_active = 1 ";
119 $res = $ilDB->query($query);
122 $server_ids[] = $row->server_id;
124 return $server_ids ? $server_ids : array();
164 $query =
"SELECT server_id FROM ldap_server_settings ORDER BY name";
165 $res = $ilDB->query($query);
168 $server_ids[] = $row->server_id;
170 return $server_ids ? $server_ids : array();
198 $this->active = $a_status;
202 return $this->active;
210 $this->url_string = $a_url;
213 $urls = explode(
',',$a_url);
216 foreach($urls as $url)
225 $this->fallback_urls[] = $url;
231 return $this->url_string;
245 include_once(
'Services/LDAP/classes/class.ilLDAPQuery.php');
247 foreach(array_merge(array(0 => $this->url),$this->fallback_urls) as $url)
255 $ilLog->write(__METHOD__.
': Using url: '.$url.
'.');
260 $ilLog->write(__METHOD__.
': Cannot connect to LDAP server: '.$url.
'. Trying fallback...');
263 $ilLog->write(__METHOD__.
': No valid LDAP server found.');
274 $this->name = $a_name;
282 $this->version = $a_version;
286 return $this->base_dn;
290 $this->base_dn = $a_base_dn;
294 return $this->referrals ?
true :
false;
298 $this->referrals = $a_status;
302 return $this->tls ?
true :
false;
306 $this->tls = $a_status;
310 return $this->binding_type;
325 return $this->bind_user;
329 $this->bind_user = $a_user;
333 return $this->bind_password;
337 $this->bind_password = $a_password;
341 return $this->search_base;
345 $this->search_base = $a_search_base;
349 return $this->user_attribute;
353 $this->user_attribute = $a_user_attr;
361 $this->filter = $a_filter;
365 return $this->group_dn;
369 $this->group_dn = $a_value;
377 $this->group_filter = $a_value;
381 return $this->group_member;
385 $this->group_member = $a_value;
389 return $this->group_name;
393 $this->group_name = $a_value;
406 if(!is_array($names))
410 foreach($names as $name)
412 $new_names[] = trim($name);
420 return $this->group_attribute;
424 $this->group_attribute = $a_value;
429 $this->group_optional = (bool) $a_status;
433 return (
bool) $this->group_optional;
437 $this->group_user_filter = $a_filter;
441 return $this->group_user_filter;
446 return (
bool) $this->memberisdn;
450 $this->memberisdn = (bool) $a_value;
454 $this->group_scope = $a_value;
458 return $this->group_scope;
462 $this->user_scope = $a_value;
466 return $this->user_scope;
470 return $this->sync_on_login;
474 $this->sync_on_login = (int) $a_value;
478 return $this->sync_per_cron;
482 $this->sync_per_cron = (int) $a_value;
486 $this->global_role = $a_role;
490 return $this->role_bind_dn;
494 $this->role_bind_dn = $a_value;
498 return $this->role_bind_pass;
502 $this->role_bind_pass = $a_value;
506 return $this->role_sync_active;
510 $this->role_sync_active = $a_value;
522 $this->account_migration = $a_status;
533 return $this->account_migration ?
true :
false;
546 $ilErr->setMessage(
'');
547 if(!strlen($this->
getName()) ||
548 !strlen($this->
getUrl()) ||
552 $ilErr->setMessage($this->lng->txt(
'fill_out_all_required_fields'));
558 $ilErr->appendMessage($this->lng->txt(
'ldap_missing_bind_user'));
563 $ilErr->appendMessage($this->lng->txt(
'ldap_missing_role_assignment'));
567 $ilErr->appendMessage($this->lng->txt(
'ldap_tls_conflict'));
570 return strlen($ilErr->getMessage()) ?
false :
true;
575 $query =
"INSERT INTO ldap_server_settings SET ".
576 "active = ".$this->db->quote($this->
isActive()).
", ".
577 "name = ".$this->db->quote($this->
getName()).
", ".
579 "version = ".$this->db->quote($this->
getVersion()).
", ".
580 "base_dn = ".$this->db->quote($this->
getBaseDN()).
", ".
582 "tls = ".$this->db->quote($this->
isActiveTLS()).
", ".
584 "bind_user = ".$this->db->quote($this->
getBindUser()).
", ".
586 "search_base = ".$this->db->quote($this->
getSearchBase()).
", ".
587 "user_scope = ".$this->db->quote($this->
getUserScope()).
", ".
589 "filter = ".$this->db->quote($this->
getFilter()).
" ";
590 "group_dn = ".$this->db->quote($this->
getGroupDN()).
", ".
591 "group_scope = ".$this->db->quote($this->
getGroupScope()).
", ".
595 "group_name = ".$this->db->quote($this->
getGroupName()).
", ".
602 "role_bind_dn = ".$this->db->quote($this->
getRoleBindDN()).
", ".
608 $this->db->query($query);
609 return $this->db->getLastInsertId();
614 $query =
"UPDATE ldap_server_settings SET ".
615 "active = ".$this->db->quote($this->
isActive()).
", ".
616 "name = ".$this->db->quote($this->
getName()).
", ".
618 "version = ".$this->db->quote($this->
getVersion()).
", ".
619 "base_dn = ".$this->db->quote($this->
getBaseDN()).
", ".
621 "tls = ".$this->db->quote($this->
isActiveTLS()).
", ".
623 "bind_user = ".$this->db->quote($this->
getBindUser()).
", ".
625 "search_base = ".$this->db->quote($this->
getSearchBase()).
", ".
626 "user_scope = ".$this->db->quote($this->
getUserScope()).
", ".
628 "filter = ".$this->db->quote($this->
getFilter()).
", ".
629 "group_dn = ".$this->db->quote($this->
getGroupDN()).
", ".
630 "group_scope = ".$this->db->quote($this->
getGroupScope()).
", ".
634 "group_name = ".$this->db->quote($this->
getGroupName()).
", ".
641 "role_bind_dn = ".$this->db->quote($this->
getRoleBindDN()).
", ".
643 "WHERE server_id = ".$this->db->quote($this->
getServerId());
645 $this->db->query($query);
667 $options[
'start_tls'] = (bool) $this->
isActiveTLS();
672 $options[
'userscope'] =
'one';
675 $options[
'userscope'] =
'sub';
680 $options[
'userfilter'] = $this->
getFilter();
684 if(@include_once(
'Log.php'))
686 if(@include_once(
'Log/observer.php'))
688 $options[
'enableLogging'] =
true;
694 $options[
'groupscope'] =
'base';
697 $options[
'groupscope'] =
'one';
700 $options[
'groupscope'] =
'sub';
723 $filter = trim($a_filter);
730 if(strpos($filter,
'(') !== 0)
732 $filter = (
'('.$filter);
734 if(substr($filter,-1) !=
')')
736 $filter = ($filter.
')');
752 include_once(
'Services/LDAP/classes/class.ilLDAPAttributeMapping.php');
753 include_once(
'Services/LDAP/classes/class.ilLDAPRoleAssignments.php');
756 $mapping->getFields(),
774 if(!$this->server_id)
778 $query =
"SELECT * FROM ldap_server_settings WHERE server_id = ".$this->db->quote($this->server_id).
"";
779 # var_dump("<pre>",$query,"</pre>");
781 $res = $this->db->query($query);