summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/password/config.inc.php.dist3
-rw-r--r--plugins/password/drivers/ldap.php10
-rw-r--r--plugins/password/drivers/ldap_simple.php12
-rw-r--r--plugins/password/package.xml1
4 files changed, 22 insertions, 4 deletions
diff --git a/plugins/password/config.inc.php.dist b/plugins/password/config.inc.php.dist
index 10a659d32..54e9e51c6 100644
--- a/plugins/password/config.inc.php.dist
+++ b/plugins/password/config.inc.php.dist
@@ -195,6 +195,9 @@ $rcmail_config['password_ldap_force_replace'] = true;
// Whenever the password is changed, the attribute will be updated if set (e.g. shadowLastChange)
$rcmail_config['password_ldap_lchattr'] = '';
+// Also try to update Samba password attributes: sambaNTPassword and sambaPwdLastSet
+$rcmail_config['password_ldap_samba'] = false;
+
// DirectAdmin Driver options
// --------------------------
diff --git a/plugins/password/drivers/ldap.php b/plugins/password/drivers/ldap.php
index 98b6636be..e4d91fe1b 100644
--- a/plugins/password/drivers/ldap.php
+++ b/plugins/password/drivers/ldap.php
@@ -92,7 +92,15 @@ function password_save($curpass, $passwd)
if (Net_LDAP2::isError($userEntry->update())) {
return PASSWORD_CONNECT_ERROR;
}
-
+
+ // Update Samba password fields, ignore errors if attributes are not found
+ if ($rcmail->config->get('password_ldap_samba')) {
+ $sambaNTPassword = hash('md4', rcube_charset_convert($passwd, RCMAIL_CHARSET, 'UTF-16LE'));
+ $userEntry->replace(array('sambaNTPassword' => $sambaNTPassword), $force);
+ $userEntry->replace(array('sambaPwdLastSet' => time()), $force);
+ $userEntry->update();
+ }
+
// All done, no error
return PASSWORD_SUCCESS;
}
diff --git a/plugins/password/drivers/ldap_simple.php b/plugins/password/drivers/ldap_simple.php
index 38db9f129..67f53d091 100644
--- a/plugins/password/drivers/ldap_simple.php
+++ b/plugins/password/drivers/ldap_simple.php
@@ -66,19 +66,25 @@ function password_save($curpass, $passwd)
}
/* Crypting new password */
- $passwd = ldap_simple_hash_password($passwd, $rcmail->config->get('password_ldap_encodage'));
- if (!$passwd) {
+ $crypted_pass = ldap_simple_hash_password($passwd, $rcmail->config->get('password_ldap_encodage'));
+ if (!$crypted_pass) {
ldap_unbind($ds);
return PASSWORD_CRYPT_ERROR;
}
- $entree[$rcmail->config->get('password_ldap_pwattr')] = $passwd;
+ $entree[$rcmail->config->get('password_ldap_pwattr')] = $crypted_pass;
/* Updating PasswordLastChange Attribute if desired */
if ($lchattr = $rcmail->config->get('password_ldap_lchattr')) {
$entree[$lchattr] = (int)(time() / 86400);
}
+ /* Update Samba password fields */
+ if ($smbattr = $rcmail->config->get('password_ldap_samba')) {
+ $sambaNTPassword = hash('md4', rcube_charset_convert($passwd, RCMAIL_CHARSET, 'UTF-16LE'));
+ $entree['sambaNTPassword'] = $sambaNTPassword;
+ $entree['sambaPwdLastSet'] = time();
+ }
if (!ldap_modify($ds, $user_dn, $entree)) {
ldap_unbind($ds);
diff --git a/plugins/password/package.xml b/plugins/password/package.xml
index 381783b97..1d63142d9 100644
--- a/plugins/password/package.xml
+++ b/plugins/password/package.xml
@@ -33,6 +33,7 @@
- Fix usage of configured temp_dir instead of /tmp (#1487447)
- ldap_simple driver: fix parse error
- ldap/ldap_simple drivers: support %dc variable in config
+- ldap/ldap_simple drivers: support Samba password change
</notes>
<contents>
<dir baseinstalldir="/" name="/">