fix user creation using LDAP Plugin

Signed-off-by: Vinicius Cubas Brand <viniciuscb@gmail.com>
This commit is contained in:
Vinicius Cubas Brand 2019-03-01 12:12:19 -03:00 committed by Morris Jobke
parent 651495e3ae
commit c4dbc428f9
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
3 changed files with 12 additions and 4 deletions

View File

@ -84,7 +84,7 @@ class UserPluginManager {
* *
* @param string $username The username of the user to create * @param string $username The username of the user to create
* @param string $password The password of the new user * @param string $password The password of the new user
* @return bool * @return string | false The user DN if user creation was successful.
* @throws \Exception * @throws \Exception
*/ */
public function createUser($username, $password) { public function createUser($username, $password) {

View File

@ -615,11 +615,19 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
* create new user * create new user
* @param string $username username of the new user * @param string $username username of the new user
* @param string $password password of the new user * @param string $password password of the new user
* @return bool was the user created? * @return bool
*/ */
public function createUser($username, $password) { public function createUser($username, $password) {
if ($this->userPluginManager->implementsActions(Backend::CREATE_USER)) { 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 \Exception("LDAP Plugin: Method createUser changed to return the user DN instead of boolean.");
}
}
return (bool) $dn;
} }
return false; return false;
} }

View File

@ -1422,7 +1422,7 @@ class User_LDAPTest extends TestCase {
->with('uid','password') ->with('uid','password')
->willReturn('result'); ->willReturn('result');
$this->assertEquals($this->backend->createUser('uid', 'password'),'result'); $this->assertEquals($this->backend->createUser('uid', 'password'),true);
} }
public function testCreateUserFailing() { public function testCreateUserFailing() {