diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-10-01 18:54:40 +0300 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-10-22 13:01:26 +0300 |
commit | 7ccd52db253ad6909092e87e89a17d8c078e01f4 (patch) | |
tree | 7069b9f4736876ab7d91f59d88fd1bbe6434699d | |
parent | a05ead505d5cd6b29119e96c95d83b6d0bdb0f98 (diff) |
lowercase configured displayname attribute so isset works - all attribute names coming from ldap are lowercased for easy comparison
-rw-r--r-- | apps/user_ldap/lib/access.php | 6 | ||||
-rw-r--r-- | apps/user_ldap/tests/access.php | 16 |
2 files changed, 17 insertions, 5 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index 4890563eb53..c1c6a8fac45 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -679,12 +679,14 @@ class Access extends LDAPUtility implements user\IUserTools { * @param array $ldapRecords */ public function batchApplyUserAttributes(array $ldapRecords){ + $displayNameAttribute = strtolower($this->connection->ldapUserDisplayName); foreach($ldapRecords as $userRecord) { - if(!isset($userRecord[$this->connection->ldapUserDisplayName])) { + if(!isset($userRecord[$displayNameAttribute])) { // displayName is obligatory continue; } - $ocName = $this->dn2ocname($userRecord['dn'], $userRecord[$this->connection->ldapUserDisplayName]); + + $ocName = $this->dn2ocname($userRecord['dn'], $userRecord[$displayNameAttribute]); if(!$ocName) { // no user name, skip. continue; diff --git a/apps/user_ldap/tests/access.php b/apps/user_ldap/tests/access.php index 5bf1a65bd51..5c535720fec 100644 --- a/apps/user_ldap/tests/access.php +++ b/apps/user_ldap/tests/access.php @@ -230,24 +230,34 @@ class Test_Access extends \Test\TestCase { $mapperMock = $this->getMockBuilder('\OCA\User_LDAP\Mapping\UserMapping') ->disableOriginalConstructor() ->getMock(); + + $mapperMock->expects($this->any()) + ->method('getNameByDN') + ->will($this->returnValue('a_username')); + $userMock = $this->getMockBuilder('\OCA\user_ldap\lib\user\User') ->disableOriginalConstructor() ->getMock(); + $access->connection->expects($this->any()) + ->method('__get') + ->will($this->returnValue('displayName')); + $access->setUserMapper($mapperMock); + $displayNameAttribute = strtolower($access->connection->ldapUserDisplayName); $data = array( array( 'dn' => 'foobar', - $con->ldapUserDisplayName => 'barfoo' + $displayNameAttribute => 'barfoo' ), array( 'dn' => 'foo', - $con->ldapUserDisplayName => 'bar' + $displayNameAttribute => 'bar' ), array( 'dn' => 'raboof', - $con->ldapUserDisplayName => 'oofrab' + $displayNameAttribute => 'oofrab' ) ); |