summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/User_LDAP.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/lib/User_LDAP.php')
-rw-r--r--apps/user_ldap/lib/User_LDAP.php32
1 files changed, 27 insertions, 5 deletions
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index 9f2468bcc85..8dfde2d8148 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -35,6 +35,7 @@
namespace OCA\User_LDAP;
+use OC\User\Backend;
use OC\User\NoUserException;
use OCA\User_LDAP\Exceptions\NotOnLDAP;
use OCA\User_LDAP\User\OfflineUser;
@@ -175,6 +176,26 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
}
/**
+ * Set password
+ * @param string $uid The username
+ * @param string $password The new password
+ * @return bool
+ */
+ public function setPassword($uid, $password) {
+ $user = $this->access->userManager->get($uid);
+
+ if(!$user instanceof User) {
+ throw new \Exception('LDAP setPassword: Could not get user object for uid ' . $uid .
+ '. Maybe the LDAP entry has no set display name attribute?');
+ }
+ if($user->getUsername() !== false) {
+ return $this->access->setPassword($user->getDN(), $password);
+ }
+
+ return false;
+ }
+
+ /**
* Get a list of all users
*
* @param string $search
@@ -449,11 +470,12 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
* compared with OC_USER_BACKEND_CREATE_USER etc.
*/
public function implementsActions($actions) {
- return (bool)((\OC\User\Backend::CHECK_PASSWORD
- | \OC\User\Backend::GET_HOME
- | \OC\User\Backend::GET_DISPLAYNAME
- | \OC\User\Backend::PROVIDE_AVATAR
- | \OC\User\Backend::COUNT_USERS)
+ return (bool)((Backend::CHECK_PASSWORD
+ | Backend::GET_HOME
+ | Backend::GET_DISPLAYNAME
+ | Backend::PROVIDE_AVATAR
+ | Backend::COUNT_USERS
+ | ((intval($this->access->connection->turnOnPasswordChange) === 1)?(Backend::SET_PASSWORD):0))
& $actions);
}