LDAP: don't fall over case insensitive LDAP attribute name

This commit is contained in:
Arthur Schiwon 2012-05-10 12:59:05 +02:00
parent a9d7c67bf2
commit 7a5028317d
1 changed files with 19 additions and 2 deletions

View File

@ -46,7 +46,12 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
if(!$dn_group || !$dn_user) {
return false;
}
$members = OC_LDAP::readAttribute($dn_group, $this->ldapGroupMemberAssocAttr);
//usually, LDAP attributes are said to be case insensitive. But there are exceptions of course.
$read = ($members = OC_LDAP::readAttribute($dn_group, $this->ldapGroupMemberAssocAttr))
|| ($members = OC_LDAP::readAttribute($dn_group, strtolower($this->ldapGroupMemberAssocAttr)));
if(!$read) {
return false;
}
//extra work if we don't get back user DNs
//TODO: this can be done with one LDAP query
@ -96,6 +101,11 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
$this->ldapGroupMemberAssocAttr.'='.$uid
));
$groups = OC_LDAP::fetchListOfGroups($filter, array(OC_LDAP::conf('ldapGroupDisplayName'),'dn'));
if(count($groups) == 0) {
//usually, LDAP attributes are said to be case insensitive. But there are exceptions... So we try it once more
$filter = str_replace($this->ldapGroupMemberAssocAttr, strtolower($this->ldapGroupMemberAssocAttr), $filter);
$groups = OC_LDAP::fetchListOfGroups($filter, array(OC_LDAP::conf('ldapGroupDisplayName'),'dn'));
}
$userGroups = OC_LDAP::ownCloudGroupNames($groups);
return array_unique($userGroups, SORT_LOCALE_STRING);
@ -110,7 +120,14 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
if(!$groupDN) {
return array();
}
$members = OC_LDAP::readAttribute($groupDN, $this->ldapGroupMemberAssocAttr);
//usually, LDAP attributes are said to be case insensitive. But there are exceptions of course.
$read = ($members = OC_LDAP::readAttribute($groupDN, $this->ldapGroupMemberAssocAttr))
|| ($members = OC_LDAP::readAttribute($groupDN, strtolower($this->ldapGroupMemberAssocAttr)));
if(!$read) {
return array();
}
$result = array();
foreach($members as $member) {
if(strtolower($this->ldapGroupMemberAssocAttr) == 'memberuid') {