Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable14] Fix user creation using LDAP Plugin #14782

Merged
merged 3 commits into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/user_ldap/lib/Group_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,7 @@ public function addToGroup($uid, $gid) {
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;
}
Expand All @@ -1188,6 +1189,7 @@ public function removeFromGroup($uid, $gid) {
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;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/UserPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function implementsActions($actions) {
*
* @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) {
Expand Down
13 changes: 11 additions & 2 deletions apps/user_ldap/lib/User_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,20 @@ public function getNewLDAPConnection($uid) {
* 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;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/tests/User_LDAPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ public function testCreateUserWithPlugin() {
->with('uid','password')
->willReturn('result');

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

public function testCreateUserFailing() {
Expand Down