X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_password-methods.inc;h=2755134f11c15115fe7420b9ffada04b9da1afc6;hb=2c7972420c32a603e35ac5454fde6fd40b31259d;hp=f580eb75882b36879383f893e0e1c56efc38e0d5;hpb=4f9cffb729176413f627caa29815f02646d157df;p=gosa.git diff --git a/include/class_password-methods.inc b/include/class_password-methods.inc index f580eb758..2755134f1 100644 --- a/include/class_password-methods.inc +++ b/include/class_password-methods.inc @@ -22,6 +22,7 @@ class passwordMethod { var $config = false; + var $attrs= array(); // Konstructor function passwordMethod($config) @@ -73,11 +74,12 @@ class passwordMethod $name = preg_replace ("/passwordMethod/i", "", $one); $test = new $one(false); if($test->is_available()) { - $ret['name'][$i]= preg_replace ("/passwordMethod/i","",$one); + $plugname= strtolower(preg_replace ("/passwordMethod/i","",$one)); + $ret['name'][$i]= $plugname; $ret['class'][$i]=$one; - $ret[$i]['name']= preg_replace("/passwordMethod/i","",$one); + $ret[$i]['name']= $plugname; $ret[$i]['class']= $one; - $ret[preg_replace ("/passwordMethod/i","",$one)]=$one; + $ret[$plugname]=$one; $i++; } } @@ -90,18 +92,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", "uid")); $attrs = $ldap->fetch (); // Set encryption type to clear if required @@ -109,8 +111,6 @@ function change_password ($dn, $password, $mode=0, $hash= "") $hash= "clear"; } - - // Detect the encryption Method if ( (isset($attrs['userPassword'][0]) && preg_match ("/^{([^}]+)}(.+)/", $attrs['userPassword'][0], $matches)) || $hash != ""){ @@ -125,6 +125,7 @@ function change_password ($dn, $password, $mode=0, $hash= "") // Crypt with the detected Method $test = new $available[$hash]($config); + $test->attrs= $attrs; $newpass = $test->generate_hash($password); } else { @@ -133,8 +134,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); @@ -154,7 +153,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(); @@ -164,15 +163,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;