ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLDAPRoleAssignmentRule Class Reference
+ Collaboration diagram for ilLDAPRoleAssignmentRule:

Public Member Functions

 matches (array $a_user_data)
 Check if a rule matches. More...
 
 setRoleId (int $a_role_id)
 set role id More...
 
 getRoleId ()
 get role id More...
 
 getRuleId ()
 get id More...
 
 setServerId (int $a_id)
 set server id More...
 
 getServerId ()
 get server id More...
 
 setType (int $a_type)
 set type More...
 
 getType ()
 getType More...
 
 setDN (string $a_dn)
 set dn More...
 
 getDN ()
 get dn More...
 
 setMemberAttribute (string $a_attribute)
 
 getMemberAttribute ()
 get attribute More...
 
 setMemberIsDN (bool $a_status)
 set member attribute is dn More...
 
 isMemberAttributeDN ()
 is member attribute dn More...
 
 setAttributeName (string $a_name)
 set attribute name More...
 
 getAttributeName ()
 get attribute name More...
 
 setAttributeValue (string $a_value)
 set attribute value More...
 
 getAttributeValue ()
 get atrtibute value More...
 
 enableAddOnUpdate (bool $a_status)
 
 isAddOnUpdateEnabled ()
 
 enableRemoveOnUpdate (bool $a_status)
 
 isRemoveOnUpdateEnabled ()
 
 setPluginId (int $a_id)
 
 getPluginId ()
 
 isPluginActive ()
 
 conditionToString ()
 
 create ()
 
 update ()
 
 validate ()
 
 delete ()
 

Static Public Member Functions

static _getInstanceByRuleId (int $a_rule_id)
 
static hasRulesForUpdate ()
 Check if there any rule for updates. More...
 
static _getRules ($a_server_id)
 Get all rules. More...
 

Data Fields

const TYPE_GROUP = 1
 
const TYPE_ATTRIBUTE = 2
 
const TYPE_PLUGIN = 3
 

Protected Member Functions

 wildcardCompare (string $a_str1, string $a_str2)
 

Private Member Functions

 __construct (int $a_rule_id=0)
 
 isGroupMember (array $a_user_data)
 Check if user is member of specific group. More...
 
 read ()
 

Private Attributes

ilLogger $logger
 
ilDBInterface $db
 
ilErrorHandling $ilErr
 
ilLanguage $lng
 
int $rule_id
 
int $server_id = 0
 
bool $add_on_update = false
 
bool $remove_on_update = false
 
int $plugin_id = 0
 
string $attribute_value = ''
 
string $attribute_name = ''
 
bool $member_is_dn = false
 
string $member_attribute = ''
 
string $dn = ''
 
int $type = 0
 
int $role_id = 0
 

Static Private Attributes

static array $instances = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLDAPRoleAssignmentRule::__construct ( int  $a_rule_id = 0)
private

Definition at line 52 of file class.ilLDAPRoleAssignmentRule.php.

References $DIC, ILIAS\Repository\lng(), ILIAS\Repository\logger(), and read().

53  {
54  global $DIC;
55  $this->db = $DIC->database();
56  $this->logger = $DIC->logger()->auth();
57  $this->ilErr = $DIC['ilErr'];
58  $this->lng = $DIC->language();
59 
60  $this->rule_id = $a_rule_id;
61  $this->read();
62  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ _getInstanceByRuleId()

static ilLDAPRoleAssignmentRule::_getInstanceByRuleId ( int  $a_rule_id)
static

◆ _getRules()

static ilLDAPRoleAssignmentRule::_getRules (   $a_server_id)
static

Get all rules.

Returns
ilLDAPRoleAssignmentRule[]

Definition at line 196 of file class.ilLDAPRoleAssignmentRule.php.

References $DIC, $ilDB, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilLDAPServer\delete(), ilLDAPSettingsGUI\getRoleAssignmentTable(), and ilLDAPSettingsGUI\roleAssignments().

196  : array
197  {
198  global $DIC;
199  $ilDB = $DIC->database();
200 
201  $rules = [];
202 
203  $query = "SELECT rule_id FROM ldap_role_assignments " .
204  "WHERE server_id = " . $ilDB->quote($a_server_id, 'integer');
205  $res = $ilDB->query($query);
206  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
207  $rules[] = self::_getInstanceByRuleId((int) $row->rule_id);
208  }
209 
210  return $rules;
211  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ conditionToString()

ilLDAPRoleAssignmentRule::conditionToString ( )

Definition at line 383 of file class.ilLDAPRoleAssignmentRule.php.

References getAttributeName(), getAttributeValue(), getDN(), getPluginId(), getType(), and ILIAS\Repository\lng().

Referenced by ilLDAPSettingsGUI\confirmDeleteRules().

383  : string
384  {
385  switch ($this->getType()) {
386  case self::TYPE_PLUGIN:
387  return $this->lng->txt('ldap_plugin_id') . ': ' . $this->getPluginId();
388 
389  case self::TYPE_GROUP:
390  $dn_arr = explode(',', $this->getDN());
391  return $dn_arr[0];
392 
393  case self::TYPE_ATTRIBUTE:
394  return $this->getAttributeName() . '=' . $this->getAttributeValue();
395 
396  default:
397  throw new RuntimeException(sprintf('Unknown type: %s', var_export($this->getType(), true)));
398  }
399  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilLDAPRoleAssignmentRule::create ( )

Definition at line 401 of file class.ilLDAPRoleAssignmentRule.php.

References getAttributeName(), getAttributeValue(), getDN(), getMemberAttribute(), getPluginId(), getRoleId(), getServerId(), getType(), isAddOnUpdateEnabled(), isMemberAttributeDN(), and isRemoveOnUpdateEnabled().

401  : bool
402  {
403  $next_id = $this->db->nextId('ldap_role_assignments');
404 
405  $query = "INSERT INTO ldap_role_assignments (server_id,rule_id,type,dn,attribute,isdn,att_name,att_value,role_id, " .
406  "add_on_update, remove_on_update, plugin_id ) " .
407  "VALUES( " .
408  $this->db->quote($this->getServerId(), 'integer') . ", " .
409  $this->db->quote($next_id, 'integer') . ", " .
410  $this->db->quote($this->getType(), 'integer') . ", " .
411  $this->db->quote($this->getDN(), 'text') . ", " .
412  $this->db->quote($this->getMemberAttribute(), 'text') . ", " .
413  $this->db->quote($this->isMemberAttributeDN(), 'integer') . ", " .
414  $this->db->quote($this->getAttributeName(), 'text') . ", " .
415  $this->db->quote($this->getAttributeValue(), 'text') . ", " .
416  $this->db->quote($this->getRoleId(), 'integer') . ", " .
417  $this->db->quote($this->isAddOnUpdateEnabled(), 'integer') . ', ' .
418  $this->db->quote($this->isRemoveOnUpdateEnabled(), 'integer') . ', ' .
419  $this->db->quote($this->getPluginId(), 'integer') . ' ' .
420  ")";
421  $this->db->manipulate($query);
422  $this->rule_id = $next_id;
423 
424  return true;
425  }
isMemberAttributeDN()
is member attribute dn
+ Here is the call graph for this function:

◆ delete()

ilLDAPRoleAssignmentRule::delete ( )

Definition at line 484 of file class.ilLDAPRoleAssignmentRule.php.

References getRuleId().

Referenced by ilLDAPSettingsGUI\deleteRules().

484  : bool
485  {
486  $query = "DELETE FROM ldap_role_assignments " .
487  "WHERE rule_id = " . $this->db->quote($this->getRuleId(), 'integer') . " ";
488  $this->db->manipulate($query);
489 
490  return true;
491  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enableAddOnUpdate()

ilLDAPRoleAssignmentRule::enableAddOnUpdate ( bool  $a_status)

Definition at line 348 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by read().

348  : void
349  {
350  $this->add_on_update = $a_status;
351  }
+ Here is the caller graph for this function:

◆ enableRemoveOnUpdate()

ilLDAPRoleAssignmentRule::enableRemoveOnUpdate ( bool  $a_status)

Definition at line 358 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by read().

358  : void
359  {
360  $this->remove_on_update = $a_status;
361  }
+ Here is the caller graph for this function:

◆ getAttributeName()

ilLDAPRoleAssignmentRule::getAttributeName ( )

get attribute name

Definition at line 327 of file class.ilLDAPRoleAssignmentRule.php.

References $attribute_name.

Referenced by conditionToString(), create(), matches(), update(), and validate().

327  : string
328  {
329  return $this->attribute_name;
330  }
+ Here is the caller graph for this function:

◆ getAttributeValue()

ilLDAPRoleAssignmentRule::getAttributeValue ( )

get atrtibute value

Definition at line 343 of file class.ilLDAPRoleAssignmentRule.php.

References $attribute_value.

Referenced by conditionToString(), create(), matches(), update(), and validate().

343  : string
344  {
345  return $this->attribute_value;
346  }
+ Here is the caller graph for this function:

◆ getDN()

ilLDAPRoleAssignmentRule::getDN ( )

get dn

Definition at line 282 of file class.ilLDAPRoleAssignmentRule.php.

References $dn.

Referenced by conditionToString(), create(), isGroupMember(), update(), and validate().

282  : string
283  {
284  return $this->dn;
285  }
+ Here is the caller graph for this function:

◆ getMemberAttribute()

ilLDAPRoleAssignmentRule::getMemberAttribute ( )

get attribute

Definition at line 295 of file class.ilLDAPRoleAssignmentRule.php.

References $member_attribute.

Referenced by create(), isGroupMember(), update(), and validate().

295  : string
296  {
298  }
+ Here is the caller graph for this function:

◆ getPluginId()

ilLDAPRoleAssignmentRule::getPluginId ( )

Definition at line 373 of file class.ilLDAPRoleAssignmentRule.php.

References $plugin_id.

Referenced by conditionToString(), create(), matches(), update(), and validate().

373  : int
374  {
375  return $this->plugin_id;
376  }
+ Here is the caller graph for this function:

◆ getRoleId()

ilLDAPRoleAssignmentRule::getRoleId ( )

get role id

Definition at line 226 of file class.ilLDAPRoleAssignmentRule.php.

References $role_id.

Referenced by create(), matches(), update(), and validate().

226  : int
227  {
228  return $this->role_id;
229  }
+ Here is the caller graph for this function:

◆ getRuleId()

ilLDAPRoleAssignmentRule::getRuleId ( )

get id

Definition at line 234 of file class.ilLDAPRoleAssignmentRule.php.

References $rule_id.

Referenced by delete(), read(), and update().

234  : int
235  {
236  return $this->rule_id;
237  }
+ Here is the caller graph for this function:

◆ getServerId()

ilLDAPRoleAssignmentRule::getServerId ( )

get server id

Definition at line 250 of file class.ilLDAPRoleAssignmentRule.php.

References $server_id.

Referenced by create(), isGroupMember(), and update().

250  : int
251  {
252  return $this->server_id;
253  }
+ Here is the caller graph for this function:

◆ getType()

ilLDAPRoleAssignmentRule::getType ( )

getType

Definition at line 266 of file class.ilLDAPRoleAssignmentRule.php.

References $type.

Referenced by conditionToString(), create(), isPluginActive(), matches(), update(), and validate().

266  : int
267  {
268  return $this->type;
269  }
+ Here is the caller graph for this function:

◆ hasRulesForUpdate()

static ilLDAPRoleAssignmentRule::hasRulesForUpdate ( )
static

Check if there any rule for updates.

Definition at line 72 of file class.ilLDAPRoleAssignmentRule.php.

References $DIC, $ilDB, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilLDAPUserSynchronisation\isUpdateRequired().

72  : bool
73  {
74  global $DIC;
75 
76  $ilDB = $DIC['ilDB'];
77 
78  $query = 'SELECT COUNT(*) num FROM ldap_role_assignments ' .
79  'WHERE add_on_update = 1 ' .
80  'OR remove_on_update = 1 ';
81  $res = $ilDB->query($query);
82  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
83 
84  return $row->num > 0;
85  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ isAddOnUpdateEnabled()

ilLDAPRoleAssignmentRule::isAddOnUpdateEnabled ( )

Definition at line 353 of file class.ilLDAPRoleAssignmentRule.php.

References $add_on_update.

Referenced by create(), and update().

353  : bool
354  {
355  return $this->add_on_update;
356  }
+ Here is the caller graph for this function:

◆ isGroupMember()

ilLDAPRoleAssignmentRule::isGroupMember ( array  $a_user_data)
private

Check if user is member of specific group.

Parameters
array$a_user_datauser_data

Definition at line 155 of file class.ilLDAPRoleAssignmentRule.php.

References Vendor\Package\$e, $res, $server, getDN(), ilLDAPServer\getInstanceByServerId(), getMemberAttribute(), getServerId(), isMemberAttributeDN(), ilLDAPServer\LDAP_SCOPE_BASE, and ILIAS\Repository\logger().

Referenced by matches().

155  : bool
156  {
158 
159  if ($this->isMemberAttributeDN()) {
160  if ($server->enabledEscapeDN()) {
161  $user_cmp = ldap_escape($a_user_data['dn'], "", LDAP_ESCAPE_FILTER);
162  } else {
163  $user_cmp = $a_user_data['dn'];
164  }
165  } else {
166  $user_cmp = $a_user_data['ilExternalAccount'];
167  }
168 
169  try {
170  $query = new ilLDAPQuery($server);
171  $query->bind();
172  $res = $query->query(
173  $this->getDN(),
174  sprintf(
175  '(%s=%s)',
176  $this->getMemberAttribute(),
177  $user_cmp
178  ),
180  array('dn')
181  );
182  return (bool) $res->numRows();
183  } catch (ilLDAPQueryException $e) {
184  $this->logger->warning(': Caught Exception: ' . $e->getMessage());
185  return false;
186  }
187  }
$res
Definition: ltiservices.php:66
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
isMemberAttributeDN()
is member attribute dn
$server
Definition: shib_login.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isMemberAttributeDN()

ilLDAPRoleAssignmentRule::isMemberAttributeDN ( )

is member attribute dn

Definition at line 311 of file class.ilLDAPRoleAssignmentRule.php.

References $member_is_dn.

Referenced by create(), isGroupMember(), and update().

311  : bool
312  {
313  return $this->member_is_dn;
314  }
+ Here is the caller graph for this function:

◆ isPluginActive()

ilLDAPRoleAssignmentRule::isPluginActive ( )

Definition at line 378 of file class.ilLDAPRoleAssignmentRule.php.

References getType().

378  : bool
379  {
380  return $this->getType() === self::TYPE_PLUGIN;
381  }
+ Here is the call graph for this function:

◆ isRemoveOnUpdateEnabled()

ilLDAPRoleAssignmentRule::isRemoveOnUpdateEnabled ( )

Definition at line 363 of file class.ilLDAPRoleAssignmentRule.php.

References $remove_on_update.

Referenced by create(), and update().

363  : bool
364  {
366  }
+ Here is the caller graph for this function:

◆ matches()

ilLDAPRoleAssignmentRule::matches ( array  $a_user_data)

Check if a rule matches.

Definition at line 90 of file class.ilLDAPRoleAssignmentRule.php.

References ilObject\_lookupTitle(), ilLDAPRoleAssignmentRules\callPlugin(), getAttributeName(), getAttributeValue(), getPluginId(), getRoleId(), getType(), isGroupMember(), ILIAS\Repository\logger(), and wildcardCompare().

90  : bool
91  {
92  switch ($this->getType()) {
93  case self::TYPE_PLUGIN:
94  return ilLDAPRoleAssignmentRules::callPlugin($this->getPluginId(), $a_user_data);
95 
96  case self::TYPE_ATTRIBUTE:
97 
98  $attn = strtolower($this->getAttributeName());
99 
100  if (!isset($a_user_data[$attn])) {
101  return false;
102  }
103 
104  if (!is_array($a_user_data[$attn])) {
105  $attribute_val = array(0 => $a_user_data[$attn]);
106  } else {
107  $attribute_val = $a_user_data[$attn];
108  }
109 
110  foreach ($attribute_val as $value) {
111  if ($this->wildcardCompare(trim($this->getAttributeValue()), trim($value))) {
112  $this->logger->debug(': Found role mapping: ' . ilObject::_lookupTitle($this->getRoleId()));
113  return true;
114  }
115  }
116  return false;
117 
118  case self::TYPE_GROUP:
119  return $this->isGroupMember($a_user_data);
120  }
121 
122  return false;
123  }
isGroupMember(array $a_user_data)
Check if user is member of specific group.
static _lookupTitle(int $obj_id)
wildcardCompare(string $a_str1, string $a_str2)
static callPlugin(int $a_plugin_id, array $a_user_data)
Call plugin check if the condition matches.
+ Here is the call graph for this function:

◆ read()

ilLDAPRoleAssignmentRule::read ( )
private

Definition at line 493 of file class.ilLDAPRoleAssignmentRule.php.

References $res, enableAddOnUpdate(), enableRemoveOnUpdate(), ilDBConstants\FETCHMODE_OBJECT, getRuleId(), setAttributeName(), setAttributeValue(), setDN(), setMemberAttribute(), setMemberIsDN(), setPluginId(), setRoleId(), setServerId(), and setType().

Referenced by __construct().

493  : void
494  {
495  $query = "SELECT * FROM ldap_role_assignments " .
496  "WHERE rule_id = " . $this->db->quote($this->getRuleId(), 'integer') . " ";
497 
498  $res = $this->db->query($query);
499  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
500  $this->setServerId((int) $row->server_id);
501  $this->setType((int) $row->type);
502  if (!is_null($row->dn)) {
503  $this->setDN($row->dn);
504  }
505  if (!is_null($row->attribute)) {
506  $this->setMemberAttribute($row->attribute);
507  }
508  $this->setMemberIsDN((bool) $row->isdn);
509  if (!is_null($row->att_name)) {
510  $this->setAttributeName($row->att_name);
511  }
512  if (!is_null($row->att_value)) {
513  $this->setAttributeValue($row->att_value);
514  }
515  $this->setRoleId((int) $row->role_id);
516  if (!is_null($row->add_on_update)) {
517  $this->enableAddOnUpdate((bool) $row->add_on_update);
518  }
519  if (!is_null($row->remove_on_update)) {
520  $this->enableRemoveOnUpdate((bool) $row->remove_on_update);
521  }
522  if (!is_null($row->plugin_id)) {
523  $this->setPluginId((int) $row->plugin_id);
524  }
525  }
526  }
$res
Definition: ltiservices.php:66
setAttributeName(string $a_name)
set attribute name
setAttributeValue(string $a_value)
set attribute value
setRoleId(int $a_role_id)
set role id
setMemberIsDN(bool $a_status)
set member attribute is dn
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAttributeName()

ilLDAPRoleAssignmentRule::setAttributeName ( string  $a_name)

set attribute name

Definition at line 319 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by read().

319  : void
320  {
321  $this->attribute_name = $a_name;
322  }
+ Here is the caller graph for this function:

◆ setAttributeValue()

ilLDAPRoleAssignmentRule::setAttributeValue ( string  $a_value)

set attribute value

Definition at line 335 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by read().

335  : void
336  {
337  $this->attribute_value = $a_value;
338  }
+ Here is the caller graph for this function:

◆ setDN()

ilLDAPRoleAssignmentRule::setDN ( string  $a_dn)

set dn

Definition at line 274 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by read().

274  : void
275  {
276  $this->dn = $a_dn;
277  }
+ Here is the caller graph for this function:

◆ setMemberAttribute()

ilLDAPRoleAssignmentRule::setMemberAttribute ( string  $a_attribute)

Definition at line 287 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by read().

287  : void
288  {
289  $this->member_attribute = $a_attribute;
290  }
+ Here is the caller graph for this function:

◆ setMemberIsDN()

ilLDAPRoleAssignmentRule::setMemberIsDN ( bool  $a_status)

set member attribute is dn

Definition at line 303 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by read().

303  : void
304  {
305  $this->member_is_dn = $a_status;
306  }
+ Here is the caller graph for this function:

◆ setPluginId()

ilLDAPRoleAssignmentRule::setPluginId ( int  $a_id)

Definition at line 368 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by read().

368  : void
369  {
370  $this->plugin_id = $a_id;
371  }
+ Here is the caller graph for this function:

◆ setRoleId()

ilLDAPRoleAssignmentRule::setRoleId ( int  $a_role_id)

set role id

Parameters
int$a_role_idrole id of global role

Definition at line 218 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by read().

218  : void
219  {
220  $this->role_id = $a_role_id;
221  }
+ Here is the caller graph for this function:

◆ setServerId()

ilLDAPRoleAssignmentRule::setServerId ( int  $a_id)

set server id

Definition at line 242 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by read().

242  : void
243  {
244  $this->server_id = $a_id;
245  }
+ Here is the caller graph for this function:

◆ setType()

ilLDAPRoleAssignmentRule::setType ( int  $a_type)

set type

Definition at line 258 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by read().

258  : void
259  {
260  $this->type = $a_type;
261  }
+ Here is the caller graph for this function:

◆ update()

ilLDAPRoleAssignmentRule::update ( )

Definition at line 427 of file class.ilLDAPRoleAssignmentRule.php.

References getAttributeName(), getAttributeValue(), getDN(), getMemberAttribute(), getPluginId(), getRoleId(), getRuleId(), getServerId(), getType(), isAddOnUpdateEnabled(), isMemberAttributeDN(), and isRemoveOnUpdateEnabled().

427  : bool
428  {
429  $query = "UPDATE ldap_role_assignments " .
430  "SET server_id = " . $this->db->quote($this->getServerId(), 'integer') . ", " .
431  "type = " . $this->db->quote($this->getType(), 'integer') . ", " .
432  "dn = " . $this->db->quote($this->getDN(), 'text') . ", " .
433  "attribute = " . $this->db->quote($this->getMemberAttribute(), 'text') . ", " .
434  "isdn = " . $this->db->quote($this->isMemberAttributeDN(), 'integer') . ", " .
435  "att_name = " . $this->db->quote($this->getAttributeName(), 'text') . ", " .
436  "att_value = " . $this->db->quote($this->getAttributeValue(), 'text') . ", " .
437  "role_id = " . $this->db->quote($this->getRoleId(), 'integer') . ", " .
438  "add_on_update = " . $this->db->quote($this->isAddOnUpdateEnabled(), 'integer') . ', ' .
439  'remove_on_update = ' . $this->db->quote($this->isRemoveOnUpdateEnabled(), 'integer') . ', ' .
440  'plugin_id = ' . $this->db->quote($this->getPluginId(), 'integer') . ' ' .
441  "WHERE rule_id = " . $this->db->quote($this->getRuleId(), 'integer') . " ";
442  $this->db->manipulate($query);
443 
444  return true;
445  }
isMemberAttributeDN()
is member attribute dn
+ Here is the call graph for this function:

◆ validate()

ilLDAPRoleAssignmentRule::validate ( )

Definition at line 447 of file class.ilLDAPRoleAssignmentRule.php.

References getAttributeName(), getAttributeValue(), getDN(), getMemberAttribute(), getPluginId(), getRoleId(), and getType().

447  : bool
448  {
449  $this->ilErr->setMessage('');
450 
451  if (!$this->getRoleId()) {
452  $this->ilErr->setMessage('fill_out_all_required_fields');
453  return false;
454  }
455  switch ($this->getType()) {
456  case self::TYPE_GROUP:
457  if ($this->getDN() === '' || $this->getMemberAttribute() === '') {
458  $this->ilErr->setMessage('fill_out_all_required_fields');
459  return false;
460  }
461  break;
462  case self::TYPE_ATTRIBUTE:
463  if ($this->getAttributeName() === '' || $this->getAttributeValue() === '') {
464  $this->ilErr->setMessage('fill_out_all_required_fields');
465  return false;
466  }
467  break;
468 
469  case self::TYPE_PLUGIN:
470  if (!$this->getPluginId()) {
471  $this->ilErr->setMessage('ldap_err_missing_plugin_id');
472  return false;
473  }
474  break;
475 
476  default:
477  $this->ilErr->setMessage('ldap_no_type_given');
478  return false;
479  }
480 
481  return true;
482  }
+ Here is the call graph for this function:

◆ wildcardCompare()

ilLDAPRoleAssignmentRule::wildcardCompare ( string  $a_str1,
string  $a_str2 
)
protected

Definition at line 125 of file class.ilLDAPRoleAssignmentRule.php.

References $message, ILIAS\Repository\logger(), and ilAuthUtils\REGEX_DELIMITERS.

Referenced by matches().

125  : bool
126  {
127  $pattern = str_replace('*', '.*?', $a_str1);
128 
129  foreach (ilAuthUtils::REGEX_DELIMITERS as $delimiter) {
130  $this->logger->debug('Trying pattern to match attribute value:' . $pattern . ' => ' . $a_str2);
131 
132  set_error_handler(static function (int $severity, string $message, string $file, int $line): never {
133  throw new ErrorException($message, $severity, $severity, $file, $line);
134  });
135 
136  try {
137  return preg_match($delimiter . "^" . $pattern . '$' . $delimiter . 'i', $a_str2) === 1;
138  } catch (Exception $ex) {
139  $this->logger->warning('Error occurred in preg_match Ex.: ' . $ex->getMessage());
140  } finally {
141  restore_error_handler();
142  }
143  }
144 
145  return false;
146  }
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $add_on_update

bool ilLDAPRoleAssignmentRule::$add_on_update = false
private

Definition at line 41 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by isAddOnUpdateEnabled().

◆ $attribute_name

string ilLDAPRoleAssignmentRule::$attribute_name = ''
private

Definition at line 45 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by getAttributeName().

◆ $attribute_value

string ilLDAPRoleAssignmentRule::$attribute_value = ''
private

Definition at line 44 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by getAttributeValue().

◆ $db

ilDBInterface ilLDAPRoleAssignmentRule::$db
private

Definition at line 34 of file class.ilLDAPRoleAssignmentRule.php.

◆ $dn

string ilLDAPRoleAssignmentRule::$dn = ''
private

Definition at line 48 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by getDN().

◆ $ilErr

ilErrorHandling ilLDAPRoleAssignmentRule::$ilErr
private

Definition at line 35 of file class.ilLDAPRoleAssignmentRule.php.

◆ $instances

array ilLDAPRoleAssignmentRule::$instances = []
staticprivate

Definition at line 31 of file class.ilLDAPRoleAssignmentRule.php.

◆ $lng

ilLanguage ilLDAPRoleAssignmentRule::$lng
private

Definition at line 36 of file class.ilLDAPRoleAssignmentRule.php.

◆ $logger

ilLogger ilLDAPRoleAssignmentRule::$logger
private

Definition at line 33 of file class.ilLDAPRoleAssignmentRule.php.

◆ $member_attribute

string ilLDAPRoleAssignmentRule::$member_attribute = ''
private

Definition at line 47 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by getMemberAttribute().

◆ $member_is_dn

bool ilLDAPRoleAssignmentRule::$member_is_dn = false
private

Definition at line 46 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by isMemberAttributeDN().

◆ $plugin_id

int ilLDAPRoleAssignmentRule::$plugin_id = 0
private

Definition at line 43 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by getPluginId().

◆ $remove_on_update

bool ilLDAPRoleAssignmentRule::$remove_on_update = false
private

Definition at line 42 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by isRemoveOnUpdateEnabled().

◆ $role_id

int ilLDAPRoleAssignmentRule::$role_id = 0
private

Definition at line 50 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by getRoleId().

◆ $rule_id

int ilLDAPRoleAssignmentRule::$rule_id
private

Definition at line 38 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by getRuleId().

◆ $server_id

int ilLDAPRoleAssignmentRule::$server_id = 0
private

Definition at line 40 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by getServerId().

◆ $type

int ilLDAPRoleAssignmentRule::$type = 0
private

Definition at line 49 of file class.ilLDAPRoleAssignmentRule.php.

Referenced by getType().

◆ TYPE_ATTRIBUTE

const ilLDAPRoleAssignmentRule::TYPE_ATTRIBUTE = 2

◆ TYPE_GROUP

const ilLDAPRoleAssignmentRule::TYPE_GROUP = 1

◆ TYPE_PLUGIN

const ilLDAPRoleAssignmentRule::TYPE_PLUGIN = 3

The documentation for this class was generated from the following file: