60 $this->rule_id = $a_id;
74 if(isset(self::$instances[$a_rule_id]))
76 return self::$instances[$a_rule_id];
89 $query =
'SELECT COUNT(*) num FROM ldap_role_assignments '.
90 'WHERE add_on_update = 1 '.
91 'OR remove_on_update = 1 ';
108 case self::TYPE_PLUGIN:
109 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
112 case self::TYPE_ATTRIBUTE:
116 if(!isset($a_user_data[$attn]))
121 if(!is_array($a_user_data[$attn]))
123 $attribute_val = array(0 => $a_user_data[$attn]);
127 $attribute_val = $a_user_data[$attn];
130 foreach($attribute_val as $value)
147 case self::TYPE_GROUP:
155 $pattern = str_replace(
'*',
'.*?', $a_str1);
156 $GLOBALS[
'ilLog']->write(__METHOD__.
': Replace pattern:'. $pattern.
' => '.$a_str2);
157 return (
bool) preg_match(
'/^'.$pattern.
'$/i',$a_str2);
175 $user_cmp = $a_user_data[
'dn'];
179 $user_cmp = $a_user_data[
'ilExternalAccount'];
182 include_once(
'Services/LDAP/classes/class.ilLDAPQuery.php');
183 include_once(
'Services/LDAP/classes/class.ilLDAPServer.php');
197 return $res->numRows() ? true :
false;
201 $ilLog->write(__METHOD__.
': Caught Exception: '.$e->getMessage());
218 $query =
"SELECT rule_id FROM ldap_role_assignments ".
219 "WHERE server_id = ".$ilDB->quote($a_server_id,
'integer');
223 $rules[] = self::_getInstanceByRuleId(
$row->rule_id);
225 return $rules ? $rules : array();
237 $this->role_id = $a_role_id;
248 return $this->role_id;
259 return $this->rule_id;
271 $this->server_id = $a_id;
294 $this->type = $a_type;
341 $this->member_attribute = $a_attribute;
352 return $this->member_attribute;
364 $this->member_is_dn = $a_status;
375 return (
bool) $this->member_is_dn;
387 $this->attribute_name = $a_name;
398 return $this->attribute_name;
410 $this->attribute_value = $a_value;
421 return $this->attribute_value;
426 $this->add_on_update = $a_status;
436 $this->remove_on_update = $a_status;
446 $this->plugin_id = $a_id;
456 return (
bool) $this->
getType() == self::TYPE_PLUGIN;
472 case self::TYPE_PLUGIN:
473 return $lng->txt(
'ldap_plugin_id').
': '.$this->
getPluginId();
475 case self::TYPE_GROUP:
476 $dn_arr = explode(
',',$this->
getDN());
480 case self::TYPE_ATTRIBUTE:
497 $next_id = $ilDB->nextId(
'ldap_role_assignments');
499 $query =
"INSERT INTO ldap_role_assignments (server_id,rule_id,type,dn,attribute,isdn,att_name,att_value,role_id, ".
500 "add_on_update, remove_on_update, plugin_id ) ".
502 $this->db->quote($this->
getServerId(),
'integer').
", ".
503 $this->db->quote($next_id,
'integer').
", ".
504 $this->db->quote($this->
getType(),
'integer').
", ".
505 $this->db->quote($this->
getDN(),
'text').
", ".
510 $this->db->quote($this->
getRoleId(),
'integer').
", ".
513 $this->db->quote($this->
getPluginId(),
'integer').
' '.
516 $this->rule_id = $next_id;
531 $query =
"UPDATE ldap_role_assignments ".
532 "SET server_id = ".$this->db->quote($this->
getServerId(),
'integer').
", ".
533 "type = ".$this->db->quote($this->
getType(),
'integer').
", ".
534 "dn = ".$this->db->quote($this->
getDN(),
'text').
", ".
539 "role_id = ".$this->db->quote($this->
getRoleId(),
'integer').
", ".
542 'plugin_id = '.$this->db->quote($this->
getPluginId(),
'integer').
' '.
543 "WHERE rule_id = ".$this->db->quote($this->
getRuleId(),
'integer').
" ";
558 $ilErr->setMessage(
'');
562 $ilErr->setMessage(
'fill_out_all_required_fields');
567 case self::TYPE_GROUP:
570 $ilErr->setMessage(
'fill_out_all_required_fields');
574 case self::TYPE_ATTRIBUTE:
577 $ilErr->setMessage(
'fill_out_all_required_fields');
582 case self::TYPE_PLUGIN:
585 $ilErr->setMessage(
'ldap_err_missing_plugin_id');
591 $ilErr->setMessage(
'ldap_no_type_given');
603 public function delete()
607 $query =
"DELETE FROM ldap_role_assignments ".
608 "WHERE rule_id = ".$this->db->quote($this->
getRuleId(),
'integer').
" ";
623 $query =
"SELECT * FROM ldap_role_assignments ".
624 "WHERE rule_id = ".$this->db->quote($this->
getRuleId(),
'integer').
" ";
_getRules($a_server_id)
Get all rules.
static _getFirstActiveServer()
Get first active server.
static hasRulesForUpdate()
Check if there any rule for updates.
matches($a_user_data)
Check if a rule matches.
enableRemoveOnUpdate($a_status)
getMemberAttribute()
get attribute
setAttributeName($a_name)
set attribute name
__construct($a_id=0)
Constructor.
isMemberAttributeDN()
is member attribute dn
static _lookupTitle($a_id)
lookup object title
isGroupMember($a_user_data)
Check if user is member of specific group.
setAttributeValue($a_value)
set attribute value
static getInstanceByServerId($a_server_id)
Get instance by server id.
const DB_FETCHMODE_OBJECT
getServerId()
get server id
wildcardCompare($a_str1, $a_str2)
getAttributeName()
get attribute name
static callPlugin($a_plugin_id, $a_user_data)
Call plugin check if the condition matches.
isRemoveOnUpdateEnabled()
setRoleId($a_role_id)
set role id
static _getInstanceByRuleId($a_rule_id)
get instance by rule id
conditionToString()
condition to string
setMemberAttribute($a_attribute)
public
enableAddOnUpdate($a_status)
setMemberIsDN($a_status)
set member attribute is dn
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
getAttributeValue()
get atrtibute value
setServerId($a_id)
set server id