diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php index 02d38ec204874..1ae6feed95317 100644 --- a/apps/user_ldap/lib/Group_LDAP.php +++ b/apps/user_ldap/lib/Group_LDAP.php @@ -1171,6 +1171,7 @@ public function addToGroup($uid, $gid) { 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 @@ public function removeFromGroup($uid, $gid) { 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 b3fda49402224..576137970cc49 100644 --- a/apps/user_ldap/lib/UserPluginManager.php +++ b/apps/user_ldap/lib/UserPluginManager.php @@ -84,7 +84,7 @@ public function implementsActions($actions) { * * @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 11ed02f47ab04..8a8bbeaa1744b 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -613,11 +613,20 @@ public function getNewLDAPConnection($uid) { * 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 693159dc72b15..f58c5f881f941 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -1422,7 +1422,7 @@ public function testCreateUserWithPlugin() { ->with('uid','password') ->willReturn('result'); - $this->assertEquals($this->backend->createUser('uid', 'password'),'result'); + $this->assertEquals($this->backend->createUser('uid', 'password'),true); } public function testCreateUserFailing() {