X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_password-methods.inc;h=97571da7900f3e6d51f3190319cc0ba9508d6e64;hb=41b3851a98576e3cd9b843a63353a9e669c4f501;hp=6dbe020daf4a35124a00e749fca7687b66aedaa2;hpb=a0cb6455b7dfb51a937c24d043fabb4f31272629;p=gosa.git diff --git a/include/class_password-methods.inc b/include/class_password-methods.inc index 6dbe020da..97571da79 100644 --- a/include/class_password-methods.inc +++ b/include/class_password-methods.inc @@ -91,16 +91,18 @@ class passwordMethod // change_password, changes the Password, of the given dn function change_password ($dn, $password, $mode=0, $hash= "") { - global $config; $newpass= ""; // Get all available encryption Methods - $available = passwordMethod::get_available_methods(); + + // NON STATIC CALL :) + $tmp = new passwordMethod($_SESSION['config']); + $available = $tmp->get_available_methods(); // read current password entry for $dn, to detect the encryption Method $ldap = $config->get_ldap_link(); - $ldap->cat ($dn); + $ldap->cat ($dn, array("shadowLastChange", "userPassword")); $attrs = $ldap->fetch (); // Set encryption type to clear if required @@ -130,8 +132,6 @@ function change_password ($dn, $password, $mode=0, $hash= "") $newpass = $test->generate_hash($password); } - - // Update shadow timestamp? if (isset($attrs["shadowLastChange"][0])){ $shadow= (int)(date("U") / 86400); @@ -151,7 +151,7 @@ function change_password ($dn, $password, $mode=0, $hash= "") } // Create SMB Password - $attrs = generate_smb_nt_hash($password); + $attrs= generate_smb_nt_hash($password); } $attrs['userPassword']= array(); @@ -161,15 +161,32 @@ function change_password ($dn, $password, $mode=0, $hash= "") $ldap->modify($attrs); - if ($ldap->error != 'Success') - { + if ($ldap->error != 'Success') { print_red(sprintf(_("Setting the password failed. LDAP server says '%s'."), $ldap->get_error())); + } else { + + /* Find postmodify entries for this class */ + $command= search_config($config->data['MENU'], "password", "POSTMODIFY"); + + if ($command != ""){ + /* Walk through attribute list */ + $command= preg_replace("/%userPassword/", $password, $command); + $command= preg_replace("/%dn/", $dn, $command); + + if (check_command($command)){ + @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute"); + exec($command); + } else { + $message= sprintf(_("Command '%s', specified as POSTMODIFY for plugin '%s' doesn't seem to exist."), $command, "password"); + print_red ($message); + } + } } } -// Retrun something like array['sambaLMPassword']= "lalla..." +// Return something like array['sambaLMPassword']= "lalla..." function generate_smb_nt_hash($password) { global $config;