Using the current ldap_authorization code, mapping rules like the following can't possibly work:
CN=administrators,OU=Groups,DC=example,DC=com|administrator
CN=underlings,OU=Groups,DC=example,DC=com|underling
I can't see how line 401 of the following code (ldap_authorization.inc lines 388-405) could be reached in the most common (where cn is a required attribute for group object):
$derive_from_entry_authorizations = array();
388: if ($consumer_conf->deriveFromEntry) {
389: foreach ($consumer_conf->deriveFromEntryEntries as $branch) {
390: $filter = '(' . $consumer_conf->deriveFromEntryAttr . '=' . $user_ldap_entry['dn'] . ')';
391: $entries = $ldap_server->search($branch, $filter, array('cn'));
392: if (empty($entries) || $entries['count'] == 0) {
393: $filter = '(' . $consumer_conf->deriveFromEntryAttr . '=' . $user->name . ')';
394: $entries = $ldap_server->search($branch, $filter, array('cn'));
395: }
396: foreach ($entries as $entry) {
397: if (isset($entry['cn'])) {
398: $derive_from_entry_authorizations[$entry['cn'][0]] = $entry['cn'][0];
399: }
400: elseif (isset($entry['dn'])) {
401: $derive_from_entry_authorizations[$entry['dn']] = (string)$entry['dn'];
402: }
403: }
404: }
405: }
Line 401 won't ever be reached because:
1. Lines 391 and 394 explicitly ask for cn attribute.
2. The cn attribute is a manditory naming attribute for group objects in most schemas, so (because of #1 above) will be returned in results.
3. cn being return in results (always) will cause excution of line 398 -- which causes the group cn to be compared against the mapping
Conclusion: Bug. I can't think of a scenario where (for "Strategy 3: groups as entries.") a user would want to use the group CN in the mapping rules. The MUCH more common approach would be to use the group's distinguished name in the mapping rules.
Suggestion: Consider explicitly requesting "dn" (not "cn" in searches) and eliminate the conditional at line 397-399. The only other way to preserve evaluation by either DN or CN would be to add a configuration setting -- which would just confuse the user since what they really want to do is use group DNs in the mapping. There's no advantage (only ambiguity in using group CNs in rules).
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 1412076.patch | 8.33 KB | johnbarclay |
Comments
Comment #1
johnbarclay commented7.x-2.x is not an active branch and this is not a bug and this issue either a feature request or support request. "Conclusion:" uses poor logic that if you can't figure out how to do what you want its a bug.
Comment #2
johnbarclay commentedComment #3
johnbarclay commentedMerging issue #1280798: LDAP Authorization: Roles not being granted to this one. Could be called feature request, could be called bug. Should be fixed in 7.x-1 and 7.x-2 as seems to be broken for most use cases.
Comment #4
johnbarclay commentedI understand that dn may be more confusing than useful, but its clearly labelled as defaulting to 'dn' it shouldn't be too much of an issue. Attached is a patch and below is the critical code to look at. The patch is confusing because it retains the old possible broken functionality for existing users of the 1.x branch.
So if a property named "deriveFromEntryUserLdapAttr" which was "dn" by default was configurable, would the following work?
Comment #5
johnbarclay commented(this is 7.x-1.x-dev).
Also the test mock server test entry for the search is:
which should work correctly if 'dn' is selected.
Comment #6
johnbarclay commentedComment #7
johnbarclay commentedthis is a duplicate of #1066608: module is not checking the OU roles object by looking for a member that is the DN, since basically II.C. has been completely reworked. After adding documentation and checking everything in, I'll update #1066608: module is not checking the OU roles object by looking for a member that is the DN.
Comment #8
kenorb commentedComment #9
kenorb commented