Merge pull request #14778 from nextcloud/user_ldap_createuser_fix

Fix user creation using LDAP Plugin
This commit is contained in:
Morris Jobke 2019-03-21 11:32:22 +01:00 committed by GitHub
commit 0155edc195
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 4 deletions

View file

@ -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;
}

View file

@ -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) {

View file

@ -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;
}

View file

@ -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() {