]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix user creation using LDAP Plugin
authorVinicius Cubas Brand <viniciuscb@gmail.com>
Fri, 1 Mar 2019 15:12:19 +0000 (12:12 -0300)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 21 Mar 2019 09:20:46 +0000 (10:20 +0100)
Signed-off-by: Vinicius Cubas Brand <viniciuscb@gmail.com>
apps/user_ldap/lib/UserPluginManager.php
apps/user_ldap/lib/User_LDAP.php
apps/user_ldap/tests/User_LDAPTest.php

index 5bf36dfe08fe58015ce7c8c2e38b445092b0940c..85eaae29daa4fe6c71f7caf54a9f820502db8031 100644 (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) {
index fbdf1cc255132ad30be1cec03b20370779c3d495..855c13e13fba65cd23741f1f7cee8dda83126ba7 100644 (file)
@@ -615,11 +615,19 @@ 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?
+        * @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 \Exception("LDAP Plugin: Method createUser changed to return the user DN instead of boolean.");
+                               }
+                       }
+                       return (bool) $dn;
                }
                return false;
        }
index 693159dc72b1521d4c1f15b72fbff436230910e4..f58c5f881f941f799a200a3c406af6627e3c1c14 100644 (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() {