ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLDAPRoleAssignmentRules Class Reference

@classDescription Do role assignemnts More...

+ Collaboration diagram for ilLDAPRoleAssignmentRules:

Static Public Member Functions

static getDefaultRole ($a_server_id)
 Get default global role. More...
 
static getAllPossibleRoles ($a_server_id)
 Get all assignable roles (used for import parser) More...
 
static getAttributeNames ($a_server_id)
 get all possible attribute names More...
 
static getAssignmentsForUpdate ($a_server_id, $a_usr_id, $a_usr_name, $a_usr_data)
 @global type $ilDB @global type $rbacadmin @global type $rbacreview @global type $ilSetting @global type $ilLog More...
 
static getAssignmentsForCreation ($a_server_id, $a_usr_name, $a_usr_data)
 
static callPlugin ($a_plugin_id, $a_user_data)
 Call plugin check if the condition matches. More...
 

Data Fields

const ROLE_ACTION_ASSIGN = 'Assign'
 
const ROLE_ACTION_DEASSIGN = 'Detach'
 

Static Protected Member Functions

static getAdditionalPluginAttributes ($a_server_id)
 Fetch additional attributes from plugin. More...
 
static parseRole ($a_role_id, $a_action)
 Parse role. More...
 

Static Protected Attributes

static $active_plugins = null
 
static $default_role = null
 

Detailed Description

@classDescription Do role assignemnts

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 32 of file class.ilLDAPRoleAssignmentRules.php.

Member Function Documentation

◆ callPlugin()

static ilLDAPRoleAssignmentRules::callPlugin (   $a_plugin_id,
  $a_user_data 
)
static

Call plugin check if the condition matches.

Returns
bool
Parameters
object$a_plugin_id
object$a_user_data

Definition at line 229 of file class.ilLDAPRoleAssignmentRules.php.

230 {
231 global $DIC;
232
233 $ilPluginAdmin = $DIC['ilPluginAdmin'];
234
235 if (self::$active_plugins == null) {
236 self::$active_plugins = $ilPluginAdmin->getActivePluginsForSlot(
238 'LDAP',
239 'ldaphk'
240 );
241 }
242
243 $assigned = false;
244 foreach (self::$active_plugins as $plugin_name) {
245 $ok = false;
246 $plugin_obj = $ilPluginAdmin->getPluginObject(
248 'LDAP',
249 'ldaphk',
250 $plugin_name
251 );
252
253 if ($plugin_obj instanceof ilLDAPRoleAssignmentPlugin) {
254 $ok = $plugin_obj->checkRoleAssignment($a_plugin_id, $a_user_data);
255 }
256
257 if ($ok) {
258 $assigned = true;
259 }
260 }
261 return $assigned;
262 }
const IL_COMP_SERVICE
Interface for ldap role assignment plugins.
global $DIC
Definition: saml.php:7

References $DIC, $ok, and IL_COMP_SERVICE.

Referenced by ilLDAPRoleAssignmentRule\matches().

+ Here is the caller graph for this function:

◆ getAdditionalPluginAttributes()

static ilLDAPRoleAssignmentRules::getAdditionalPluginAttributes (   $a_server_id)
staticprotected

Fetch additional attributes from plugin.

Parameters
int$a_server_id
Returns

Definition at line 271 of file class.ilLDAPRoleAssignmentRules.php.

272 {
273 global $DIC;
274
275 $ilPluginAdmin = $DIC['ilPluginAdmin'];
276
277 if (self::$active_plugins == null) {
278 self::$active_plugins = $ilPluginAdmin->getActivePluginsForSlot(
280 'LDAP',
281 'ldaphk'
282 );
283 }
284
285 $attributes = array();
286 foreach (self::$active_plugins as $plugin_name) {
287 $ok = false;
288 $plugin_obj = $ilPluginAdmin->getPluginObject(
290 'LDAP',
291 'ldaphk',
292 $plugin_name
293 );
294
295 if ($plugin_obj instanceof ilLDAPRoleAssignmentPlugin) {
296 $attributes = array_merge($attributes, $plugin_obj->getAdditionalAttributeNames());
297 }
298 }
299 return $attributes ? $attributes : array();
300 }
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85

References $attributes, $DIC, $ok, and IL_COMP_SERVICE.

◆ getAllPossibleRoles()

static ilLDAPRoleAssignmentRules::getAllPossibleRoles (   $a_server_id)
static

Get all assignable roles (used for import parser)

Parameters
int$a_server_id
Returns
array roles

Definition at line 60 of file class.ilLDAPRoleAssignmentRules.php.

61 {
62 global $DIC;
63
64 $ilDB = $DIC['ilDB'];
65
66 $query = "SELECT DISTINCT(role_id) FROM ldap_role_assignments " .
67 'WHERE server_id = ' . $ilDB->quote($a_server_id, 'integer');
68 $res = $ilDB->query($query);
69 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
70 $roles[$row->role_id] = $row->role_id;
71 }
72 $gr = self::getDefaultRole($a_server_id);
73 $roles[$gr] = $gr;
74 return $roles ? $roles : array();
75 }
static getDefaultRole($a_server_id)
Get default global role.
$row
$query
foreach($_POST as $key=> $value) $res
global $ilDB

References $DIC, $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, and getDefaultRole().

Referenced by ilLDAPAttributeToUser\refresh().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssignmentsForCreation()

static ilLDAPRoleAssignmentRules::getAssignmentsForCreation (   $a_server_id,
  $a_usr_name,
  $a_usr_data 
)
static
Returns
array role data
Parameters
int$a_server_id
object$a_usr_id
object$a_usr_data

@access public

Definition at line 179 of file class.ilLDAPRoleAssignmentRules.php.

180 {
181 global $DIC;
182
183 $ilDB = $DIC['ilDB'];
184 $ilLog = $DIC['ilLog'];
185
186 $query = "SELECT rule_id FROM ldap_role_assignments " .
187 'WHERE server_id = ' . $ilDB->quote($a_server_id, 'integer');
188 $res = $ilDB->query($query);
189
190 $num_matches = 0;
191 $roles = array();
192 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
193 include_once './Services/LDAP/classes/class.ilLDAPRoleAssignmentRule.php';
195
196 if ($rule->matches($a_usr_data)) {
197 $num_matches++;
198 $ilLog->info(': Assigned to role: ' . $a_usr_name . ' => ' . ilObject::_lookupTitle($rule->getRoleId()));
199 $roles[] = self::parseRole($rule->getRoleId(), self::ROLE_ACTION_ASSIGN);
200 }
201 }
202
203 // DONE: check for global role
204 $found_global = false;
205 foreach ($roles as $role_data) {
206 if ($role_data['type'] == 'Global') {
207 $found_global = true;
208 break;
209 }
210 }
211 if (!$found_global) {
212 $ilLog->info(': No matching rule found. Assigning to default role.');
213 $roles[] = self::parseRole(
214 self::getDefaultRole($a_server_id),
215 self::ROLE_ACTION_ASSIGN
216 );
217 }
218
219 return $roles ? $roles : array();
220 }
static _getInstanceByRuleId($a_rule_id)
get instance by rule id
static parseRole($a_role_id, $a_action)
Parse role.
static _lookupTitle($a_id)
lookup object title
$rule
Definition: showstats.php:43

References $DIC, $ilDB, $ilLog, $query, $res, $row, $rule, ilLDAPRoleAssignmentRule\_getInstanceByRuleId(), ilObject\_lookupTitle(), ilDBConstants\FETCHMODE_OBJECT, and parseRole().

Referenced by ilLDAPAttributeToUser\parseRoleAssignmentsForCreation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssignmentsForUpdate()

static ilLDAPRoleAssignmentRules::getAssignmentsForUpdate (   $a_server_id,
  $a_usr_id,
  $a_usr_name,
  $a_usr_data 
)
static

@global type $ilDB @global type $rbacadmin @global type $rbacreview @global type $ilSetting @global type $ilLog

Parameters
int$a_server_id
type$a_usr_id
type$a_usr_name
type$a_usr_data
Returns
array

Definition at line 118 of file class.ilLDAPRoleAssignmentRules.php.

119 {
120 global $DIC;
121
122 $ilDB = $DIC['ilDB'];
123 $rbacadmin = $DIC['rbacadmin'];
124 $rbacreview = $DIC['rbacreview'];
125 $ilSetting = $DIC['ilSetting'];
126 $ilLog = $DIC['ilLog'];
127
128 $query = "SELECT rule_id,add_on_update,remove_on_update FROM ldap_role_assignments " .
129 "WHERE (add_on_update = 1 OR remove_on_update = 1) " .
130 'AND server_id = ' . $ilDB->quote($a_server_id, 'integer');
131
132 $res = $ilDB->query($query);
133 $roles = array();
134 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
135 include_once './Services/LDAP/classes/class.ilLDAPRoleAssignmentRule.php';
137
138 $matches = $rule->matches($a_usr_data);
139 if ($matches and $row->add_on_update) {
140 $ilLog->info(': Assigned to role: ' . $a_usr_name . ' => ' . ilObject::_lookupTitle($rule->getRoleId()));
141 $roles[] = self::parseRole($rule->getRoleId(), self::ROLE_ACTION_ASSIGN);
142 }
143 if (!$matches and $row->remove_on_update) {
144 $ilLog->info(': Deassigned from role: ' . $a_usr_name . ' => ' . ilObject::_lookupTitle($rule->getRoleId()));
145 $roles[] = self::parseRole($rule->getRoleId(), self::ROLE_ACTION_DEASSIGN);
146 }
147 }
148
149 // Check if there is minimum on global role
150 $deassigned_global = 0;
151 foreach ($roles as $role_data) {
152 if ($role_data['type'] == 'Global' and
153 $role_data['action'] == self::ROLE_ACTION_DEASSIGN) {
154 $deassigned_global++;
155 }
156 }
157 if (count($rbacreview->assignedGlobalRoles($a_usr_id)) == $deassigned_global) {
158 $ilLog->info(': No global role left. Assigning to default role.');
159 $roles[] = self::parseRole(
160 self::getDefaultRole($a_server_id),
161 self::ROLE_ACTION_ASSIGN
162 );
163 }
164
165 return $roles ? $roles : array();
166 }
global $ilSetting
Definition: privfeed.php:17

References $DIC, $ilDB, $ilLog, $ilSetting, $query, $res, $row, $rule, ilLDAPRoleAssignmentRule\_getInstanceByRuleId(), ilObject\_lookupTitle(), ilDBConstants\FETCHMODE_OBJECT, and parseRole().

Referenced by ilLDAPAttributeToUser\parseRoleAssignmentsForUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAttributeNames()

static ilLDAPRoleAssignmentRules::getAttributeNames (   $a_server_id)
static

get all possible attribute names

Parameters
int$a_server_id
Returns

Definition at line 83 of file class.ilLDAPRoleAssignmentRules.php.

84 {
85 global $DIC;
86
87 $ilDB = $DIC['ilDB'];
88
89 $query = "SELECT DISTINCT(att_name) " .
90 "FROM ldap_role_assignments " .
91 'WHERE server_id = ' . $ilDB->quote($a_server_id, 'integer');
92 $res = $ilDB->query($query);
93 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
94 $name = strtolower(trim($row->att_name));
95 if ($name) {
96 $names[] = $name;
97 }
98 }
99
100 $names = array_merge((array) $names, self::getAdditionalPluginAttributes($a_server_id));
101 return $names ? $names : array();
102 }

References $DIC, $ilDB, $name, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilLDAPQuery\fetchUserProfileFields(), and ilLDAPServer\getPearAtributeArray().

+ Here is the caller graph for this function:

◆ getDefaultRole()

static ilLDAPRoleAssignmentRules::getDefaultRole (   $a_server_id)
static

Get default global role.

Parameters
int$a_server_id
Returns

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

47 {
48 include_once './Services/LDAP/classes/class.ilLDAPAttributeMapping.php';
49 include_once './Services/LDAP/classes/class.ilLDAPServer.php';
50
51 return self::$default_role =
53 }
static _lookupGlobalRole($a_server_id)
Lookup global role assignment.

References ilLDAPAttributeMapping\_lookupGlobalRole().

Referenced by getAllPossibleRoles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseRole()

static ilLDAPRoleAssignmentRules::parseRole (   $a_role_id,
  $a_action 
)
staticprotected

Parse role.

Returns
Parameters
int$a_role_id
string$a_action

Definition at line 309 of file class.ilLDAPRoleAssignmentRules.php.

310 {
311 global $DIC;
312
313 $rbacreview = $DIC['rbacreview'];
314
315 return array(
316 'id' => $a_role_id,
317 'type' => $rbacreview->isGlobalRole($a_role_id) ? 'Global' : 'Local',
318 'action' => $a_action
319 );
320 }

References $DIC.

Referenced by getAssignmentsForCreation(), and getAssignmentsForUpdate().

+ Here is the caller graph for this function:

Field Documentation

◆ $active_plugins

ilLDAPRoleAssignmentRules::$active_plugins = null
staticprotected

Definition at line 37 of file class.ilLDAPRoleAssignmentRules.php.

◆ $default_role

ilLDAPRoleAssignmentRules::$default_role = null
staticprotected

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

◆ ROLE_ACTION_ASSIGN

const ilLDAPRoleAssignmentRules::ROLE_ACTION_ASSIGN = 'Assign'

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

◆ ROLE_ACTION_DEASSIGN

const ilLDAPRoleAssignmentRules::ROLE_ACTION_DEASSIGN = 'Detach'

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


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