31 include_once(
'Services/LDAP/classes/class.ilLDAPRoleAssignmentRule.php');
58 $this->server = $a_server;
59 $this->server_id = $this->server->getServerId();
79 if(isset(self::$instances[$a_server_id]))
81 return self::$instances[$a_server_id];
98 $query =
"SELECT DISTINCT(att_name) as att FROM ldap_role_assignments ".
99 "WHERE type = ".ilLDAPRoleAssignmentRule::TYPE_ATTRIBUTE.
" ".
100 "AND server_id = ".$ilDB->quote($a_server_id).
" ";
101 $res = $ilDB->query($query);
104 $attributes[] = strtolower(trim($row->att));
106 return $attributes ? $attributes : array();
119 return $this->all_roles ? $this->all_roles : array();
134 $default_roles[] = array(
'id' => $this->default_role,
136 'action' =>
'Attach');
137 $ilLog->write(__METHOD__.
': Fetch assignable roles...');
138 foreach($this->att_mappings as $name => $values)
140 if(!isset($a_user_att[$name]))
145 if(!is_array($a_user_att[$name]))
147 $attribute_val = array(0 => $a_user_att[$name]);
151 $attribute_val = $a_user_att[$name];
154 foreach($attribute_val as $value)
156 $value = strtolower($value);
157 if(!isset($this->att_mappings[$name][$value]))
163 $role = $this->att_mappings[$name][$value];
164 $ilLog->write(__METHOD__.
': Found role mapping for '.$a_external_name.
' => '.
ilObject::_lookupTitle($role));
165 $roles[] = array(
'id' => $role,
167 'action' =>
'Attach');
173 foreach($this->grp_mappings as $dn => $mapping_data)
177 $ilLog->write(__METHOD__.
': Found LDAP group => role mapping for '.$a_external_name.
' => '.
ilObject::_lookupTitle($mapping_data[
'role']));
178 $roles[] = array(
'id' => $mapping_data[
'role'],
180 'action' =>
'Attach');
185 return $roles ? $roles : $default_roles;
202 if($this->grp_mappings[$a_dn][
'isdn'])
204 $user_cmp = $a_user_data[
'dn'];
208 $user_cmp = $a_ldap_account;
211 include_once(
'Services/LDAP/classes/class.ilLDAPQuery.php');
212 include_once(
'Services/LDAP/classes/class.ilLDAPServer.php');
219 $res = $query->query($a_dn,
221 $this->grp_mappings[$a_dn][
'attribute'],
226 return $res->numRows() ?
true :
false;
230 $ilLog->write(__METHOD__.
': Caught Exception: '.$e->getMessage());
243 $query =
"SELECT * FROM ldap_role_assignments ".
244 "WHERE server_id = ".$this->db->quote($this->server_id).
" ".
245 "AND type = ".ilLDAPRoleAssignmentRule::TYPE_ATTRIBUTE.
" ";
246 $res = $this->db->query($query);
249 $this->att_mappings[strtolower($row->att_name)][strtolower($row->att_value)] = $row->role_id;
250 $this->all_roles[$row->role_id] = $row->role_id;
262 $query =
"SELECT * FROM ldap_role_assignments ".
263 "WHERE server_id = ".$this->db->quote($this->server_id).
" ".
264 "AND type = ".ilLDAPRoleAssignmentRule::TYPE_GROUP.
" ";
265 $res = $this->db->query($query);
268 $this->grp_mappings[strtolower($row->dn)][
'attribute'] = strtolower($row->attribute);
269 $this->grp_mappings[strtolower($row->dn)][
'isdn'] = $row->isdn;
270 $this->grp_mappings[strtolower($row->dn)][
'role'] = $row->role_id;
272 $this->all_roles[$row->role_id] = $row->role_id;
286 include_once(
'Services/LDAP/classes/class.ilLDAPAttributeMapping.php');