Skip to content

Commit 62ab9e0

Browse files
committed
fix user creation using LDAP Plugin
Signed-off-by: Vinicius Cubas Brand <[email protected]>
1 parent df55781 commit 62ab9e0

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

apps/user_ldap/lib/UserPluginManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function implementsActions($actions) {
8484
*
8585
* @param string $username The username of the user to create
8686
* @param string $password The password of the new user
87-
* @return bool
87+
* @return string | false The user DN if user creation was successful.
8888
* @throws \Exception
8989
*/
9090
public function createUser($username, $password) {

apps/user_ldap/lib/User_LDAP.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,19 @@ public function getNewLDAPConnection($uid) {
615615
* create new user
616616
* @param string $username username of the new user
617617
* @param string $password password of the new user
618-
* @return bool was the user created?
618+
* @return bool
619619
*/
620620
public function createUser($username, $password) {
621621
if ($this->userPluginManager->implementsActions(Backend::CREATE_USER)) {
622-
return $this->userPluginManager->createUser($username, $password);
622+
if ($dn = $this->userPluginManager->createUser($username, $password)) {
623+
if (is_string($dn)) {
624+
//updates user mapping
625+
$this->access->dn2ocname($dn, $username, true);
626+
} else {
627+
throw new \Exception("LDAP Plugin: Method createUser changed to return the user DN instead of boolean.");
628+
}
629+
}
630+
return (bool) $dn;
623631
}
624632
return false;
625633
}

apps/user_ldap/tests/User_LDAPTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ public function testCreateUserWithPlugin() {
14221422
->with('uid','password')
14231423
->willReturn('result');
14241424

1425-
$this->assertEquals($this->backend->createUser('uid', 'password'),'result');
1425+
$this->assertEquals($this->backend->createUser('uid', 'password'),true);
14261426
}
14271427

14281428
public function testCreateUserFailing() {

0 commit comments

Comments
 (0)