diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-03-21 11:32:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-21 11:32:22 +0100 |
commit | 0155edc195ed278a2a4d06c15295433ae0ae8445 (patch) | |
tree | 3192a0018c8d9ad1c41c2760e944916d39f817f2 | |
parent | 651495e3ae549b4c029e2ca177a696fa9701ba4e (diff) | |
parent | 61572a5b2e92182c6fea17855abd9b2b4f942334 (diff) | |
download | nextcloud-server-0155edc195ed278a2a4d06c15295433ae0ae8445.tar.gz nextcloud-server-0155edc195ed278a2a4d06c15295433ae0ae8445.zip |
Merge pull request #14778 from nextcloud/user_ldap_createuser_fix
Fix user creation using LDAP Plugin
-rw-r--r-- | apps/user_ldap/lib/Group_LDAP.php | 2 | ||||
-rw-r--r-- | apps/user_ldap/lib/UserPluginManager.php | 2 | ||||
-rw-r--r-- | apps/user_ldap/lib/User_LDAP.php | 13 | ||||
-rw-r--r-- | apps/user_ldap/tests/User_LDAPTest.php | 2 |
4 files changed, 15 insertions, 4 deletions
diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php index 1658807c0dd..cd4bd18cb44 100644 --- a/apps/user_ldap/lib/Group_LDAP.php +++ b/apps/user_ldap/lib/Group_LDAP.php @@ -1171,6 +1171,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD if ($this->groupPluginManager->implementsActions(GroupInterface::ADD_TO_GROUP)) { if ($ret = $this->groupPluginManager->addToGroup($uid, $gid)) { $this->access->connection->clearCache(); + unset($this->cachedGroupMembers[$gid]); } return $ret; } @@ -1188,6 +1189,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD if ($this->groupPluginManager->implementsActions(GroupInterface::REMOVE_FROM_GROUP)) { if ($ret = $this->groupPluginManager->removeFromGroup($uid, $gid)) { $this->access->connection->clearCache(); + unset($this->cachedGroupMembers[$gid]); } return $ret; } diff --git a/apps/user_ldap/lib/UserPluginManager.php b/apps/user_ldap/lib/UserPluginManager.php index 5bf36dfe08f..85eaae29daa 100644 --- a/apps/user_ldap/lib/UserPluginManager.php +++ b/apps/user_ldap/lib/UserPluginManager.php @@ -84,7 +84,7 @@ class UserPluginManager { * * @param string $username The username of the user to create * @param string $password The password of the new user - * @return bool + * @return string | false The user DN if user creation was successful. * @throws \Exception */ public function createUser($username, $password) { diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index fbdf1cc2551..e69eafecc86 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -615,11 +615,20 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn * create new user * @param string $username username of the new user * @param string $password password of the new user - * @return bool was the user created? + * @throws \UnexpectedValueException + * @return bool */ public function createUser($username, $password) { if ($this->userPluginManager->implementsActions(Backend::CREATE_USER)) { - return $this->userPluginManager->createUser($username, $password); + if ($dn = $this->userPluginManager->createUser($username, $password)) { + if (is_string($dn)) { + //updates user mapping + $this->access->dn2ocname($dn, $username, true); + } else { + throw new \UnexpectedValueException("LDAP Plugin: Method createUser changed to return the user DN instead of boolean."); + } + } + return (bool) $dn; } return false; } diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index 693159dc72b..f58c5f881f9 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -1422,7 +1422,7 @@ class User_LDAPTest extends TestCase { ->with('uid','password') ->willReturn('result'); - $this->assertEquals($this->backend->createUser('uid', 'password'),'result'); + $this->assertEquals($this->backend->createUser('uid', 'password'),true); } public function testCreateUserFailing() { |