24 assert(
'is_array($request)');
25 assert(
'array_key_exists("Attributes", $request)');
29 $this->title .
'Attempting to get the users groups...' 47 $this->title .
'The group attribute [' . $map[
'groups'] .
54 $group_attribute = array_merge($group_attribute, $groups);
55 $group_attribute = array_unique($group_attribute);
59 $this->title .
'Added users groups to the group attribute [' .
60 $map[
'groups'] .
']: ' . implode(
'; ', $groups)
83 $this->title .
'Checking for groups based on the best method for the LDAP product.' 88 switch ($this->product) {
90 case 'ACTIVEDIRECTORY':
94 $this->title .
'Searching LDAP using ActiveDirectory specific method.' 98 if (!isset($attributes[$map[
'dn']])) {
100 $this->title .
'The DN attribute [' . $map[
'dn'] .
101 '] is not defined in the users Attributes: ' . implode(
', ', array_keys($attributes))
106 if (!isset($attributes[$map[
'dn']][0]) || !$attributes[$map[
'dn']][0]) {
108 $this->title .
'The DN attribute [' . $map[
'dn'] .
109 '] does not have a [0] value defined. ' . $this->
var_export($attributes[$map[
'dn']])
120 $this->title .
'Searching LDAP using OpenLDAP specific method.' 123 $openldap_base = $this->config->getString(
'ldap.basedn',
'ou=groups,dc=example,dc=com');
125 $this->title .
"Searching for groups in ldap.basedn ".$openldap_base.
" with filter (".$map[
'memberof'].
"=".$attributes[$map[
'username']][0].
") and attributes ".$map[
'member']
130 $all_groups = $this->
getLdap()->searchformultiple( $openldap_base,
array($map[
'memberof'] => $attributes[$map[
'username']][0]) ,
array($map[
'member']));
135 foreach ($all_groups as $group_entry) {
136 $groups[] .= $group_entry[$map[
'member']][0];
144 $this->title .
'Searching LDAP using the default search method.' 148 if (!isset($attributes[$map[
'memberof']])) {
150 $this->title .
'The memberof attribute [' . $map[
'memberof'] .
151 '] is not defined in the users Attributes: ' . implode(
', ', array_keys($attributes))
156 if (!is_array($attributes[$map[
'memberof']])) {
158 $this->title .
'The memberof attribute [' . $map[
'memberof'] .
159 '] is not an array of group DNs. ' . $this->
var_export($attributes[$map[
'memberof']])
164 $groups = $this->
search($attributes[$map[
'memberof']]);
169 $this->title .
'User found to be a member of the groups:' . implode(
'; ', $groups)
186 assert(
'is_array($memberof)');
189 static $searched =
array();
199 $this->title .
'Checking DNs for groups.' .
200 ' DNs: '. implode(
'; ', $memberof) .
201 ' Attributes: ' . $map[
'memberof'] .
', ' . $map[
'type'] .
202 ' Group Type: ' . $this->type_map[
'group']
206 foreach ($memberof as $dn) {
209 if (isset($searched[$dn])) {
215 $searched[$dn] = $dn;
225 if (!in_array($this->type_map[
'group'],
$attributes[$map[
'type']],
true)) {
237 return array_unique($groups);
251 assert(
'is_string($dn) && $dn != ""');
258 $this->title .
'Searching ActiveDirectory group membership.' .
260 ' DN Attribute: ' . $map[
'dn'] .
261 ' Member Attribute: ' . $map[
'member'] .
262 ' Type Attribute: ' . $map[
'type'] .
263 ' Type Value: ' . $this->type_map[
'group'] .
264 ' Base: ' . implode(
'; ', $this->base_dn)
268 $this->
getLdap()->setOption(LDAP_OPT_REFERRALS, 0);
272 $entries = $this->
getLdap()->searchformultiple(
274 array($map[
'type'] => $this->type_map[
'group'], $map[
'member'] .
':1.2.840.113556.1.4.1941:' => $dn),
288 foreach ($entries as $entry) {
291 if (isset($entry[$map[
'dn']][0])) {
292 $groups[] = $entry[$map[
'dn']][0];
297 if (isset($entry[strtolower($map[
'dn'])][0])) {
298 $groups[] = $entry[strtolower($map[
'dn'])][0];
303 if (isset($entry[
'dn'])) {
304 $groups[] = $entry[
'dn'];
310 $this->title .
'The DN attribute [' .
311 implode(
', ',
array($map[
'dn'], strtolower($map[
'dn']),
'dn')) .
312 '] could not be found in the entry. ' . $this->
var_export($entry)
searchActiveDirectory($dn)
Searches LDAP using a ActiveDirectory specific filter, looking for group membership for the users DN...
var_export($value)
Local utility function to get details about a variable, basically converting it to a string to be use...
Create styles array
The data for the language used.
process(&$request)
This is run when the filter is processed by SimpleSAML.
getLdap()
Getter for the LDAP connection object.
getGroups(array $attributes)
This section of code was broken out because the child filter AuthorizeByGroup can use this method as ...
search($memberof)
Looks for groups from the list of DN's passed.