mirror of
https://github.com/dducret/kopano-webapp-passwd
synced 2026-07-27 18:42:47 +02:00
Update sambaNTPassword for users who have a sambaSamAccount objectclass
This commit is contained in:
parent
a0b6a813fc
commit
2e39b60f5b
1 changed files with 7 additions and 3 deletions
|
|
@ -114,12 +114,12 @@ class PasswdModule extends Module
|
||||||
$ldapconn, // connection-identify
|
$ldapconn, // connection-identify
|
||||||
PLUGIN_PASSWD_LDAP_BASEDN, // basedn
|
PLUGIN_PASSWD_LDAP_BASEDN, // basedn
|
||||||
'uid=' . $uid, // search filter
|
'uid=' . $uid, // search filter
|
||||||
array('dn') // needed attributes. we need the dn
|
array('dn', 'objectClass') // needed attributes. we need dn and objectclass
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($userdn) {
|
if ($userdn) {
|
||||||
$userdn = ldap_get_entries($ldapconn, $userdn);
|
$entries = ldap_get_entries($ldapconn, $userdn);
|
||||||
$userdn = $userdn[0]['dn'];
|
$userdn = $entries[0]['dn'];
|
||||||
|
|
||||||
// bind to ldap directory
|
// bind to ldap directory
|
||||||
// login with current password if that fails then current password is wrong
|
// login with current password if that fails then current password is wrong
|
||||||
|
|
@ -132,6 +132,10 @@ class PasswdModule extends Module
|
||||||
if ($this->checkPasswordStrenth($passwd)) {
|
if ($this->checkPasswordStrenth($passwd)) {
|
||||||
$password_hash = $this->sshaEncode($passwd);
|
$password_hash = $this->sshaEncode($passwd);
|
||||||
$entry = array('userPassword' => $password_hash);
|
$entry = array('userPassword' => $password_hash);
|
||||||
|
if (in_array('sambaSamAccount', $entries[0]['objectclass'])) {
|
||||||
|
$nthash = strtoupper(bin2hex(mhash(MHASH_MD4, iconv("UTF-8","UTF-16LE", $passwd))));
|
||||||
|
$entry['sambaNTPassword'] = $nthash;
|
||||||
|
}
|
||||||
ldap_modify($ldapconn, $userdn, $entry);
|
ldap_modify($ldapconn, $userdn, $entry);
|
||||||
if (ldap_errno($ldapconn) === 0) {
|
if (ldap_errno($ldapconn) === 0) {
|
||||||
// password changed successfully
|
// password changed successfully
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue