Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2019-03-21 15:53:55 +0300
committerGitHub <noreply@github.com>2019-03-21 15:53:55 +0300
commit2e30a5d10705fae41b7b74e68cedcfbf85412bd7 (patch)
tree6112ba45b89a59b1158902a2379addd961cba90c
parent2c7f1fd001b6f442ed9b32b17d68371cf3f74e2d (diff)
parent79b7f12a79013a48ac03d18e9f195f2a5e5309f4 (diff)
Merge pull request #14781 from nextcloud/backport/14778/stable15
[stable15] Fix user creation using LDAP Plugin
-rw-r--r--apps/user_ldap/lib/Group_LDAP.php2
-rw-r--r--apps/user_ldap/lib/UserPluginManager.php2
-rw-r--r--apps/user_ldap/lib/User_LDAP.php13
-rw-r--r--apps/user_ldap/tests/User_LDAPTest.php2
4 files changed, 15 insertions, 4 deletions
diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php
index 1658807c0dd..cd4bd18cb44 100644
--- a/apps/user_ldap/lib/Group_LDAP.php
+++ b/apps/user_ldap/lib/Group_LDAP.php
@@ -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;
}
diff --git a/apps/user_ldap/lib/UserPluginManager.php b/apps/user_ldap/lib/UserPluginManager.php
index b3fda494022..576137970cc 100644
--- a/apps/user_ldap/lib/UserPluginManager.php
+++ b/apps/user_ldap/lib/UserPluginManager.php
@@ -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) {
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index fbdf1cc2551..e69eafecc86 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -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;
}
diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php
index 693159dc72b..f58c5f881f9 100644
--- a/apps/user_ldap/tests/User_LDAPTest.php
+++ b/apps/user_ldap/tests/User_LDAPTest.php
@@ -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() {