index 97571da7900f3e6d51f3190319cc0ba9508d6e64..8d9021a4cf8d481fbbd91366dd12bc5787be349a 100644 (file)
class passwordMethod
{
var $config = false;
+ var $attrs= array();
// Konstructor
function passwordMethod($config)
// read current password entry for $dn, to detect the encryption Method
$ldap = $config->get_ldap_link();
- $ldap->cat ($dn, array("shadowLastChange", "userPassword"));
+ $ldap->cat ($dn, array("shadowLastChange", "userPassword", "uid"));
$attrs = $ldap->fetch ();
- // Set encryption type to clear if required
- if (isset($attrs['userPassword'][0]) && preg_match('/^[^{}]+$/', $attrs['userPassword'][0]) && $hash == ""){
- $hash= "clear";
+ // Check if user account was deactivated, indicated by ! after } ... {crypt}!###
+ if(isset($attrs['userPassword'][0]) && preg_match("/^[^\}]*+\}!/",$attrs['userPassword'][0])){
+ $deactivated = TRUE;
+ }else{
+ $deactivated = FALSE;
+ }
+
+# // Get current password hash method if available
+# if($hash == "" && isset($attrs['userPassword'][0]) && preg_match("/[\{\}]/",$attrs['userPassword'][0])){
+# $hash = preg_replace("/^[^\{]*+\{([^\}]*).*$/","\\1",$attrs['userPassword'][0]);
+# $hash = strtolower($hash);
+# }
+
+# // Set encryption type to clear if required
+# if (!isset($attrs['userPassword'][0]) || $hash == ""){
+# $hash= "clear";
+# }
+
+ /* Is ensure that clear passwords will stay clear */
+ if($hash == "" && isset($attrs['userPassword'][0]) && !preg_match ("/^{([^}]+)}(.+)/", $attrs['userPassword'][0])){
+ $hash = "clear";
}
// Detect the encryption Method
$hash= strtolower($matches[1]);
}
-
// Crypt with the detected Method
$test = new $available[$hash]($config);
+ $test->attrs= $attrs;
$newpass = $test->generate_hash($password);
} else {
$attrs= generate_smb_nt_hash($password);
}
+ /* Readd ! if user was deactivated */
+ if($deactivated){
+ $newpass = preg_replace("/(^[^\}]+\})(.*$)/","\\1!\\2",$newpass);
+ }
+
$attrs['userPassword']= array();
$attrs['userPassword']= $newpass;
$hash= current($ar);
if ($hash == "")
{
- print_red (_("Setting for SMBHASH in gosa.conf is incorrect! Can't change Samba password."));
+ print_red (sprintf(_("Setting for SMBHASH in %s is incorrect! Can't change Samba password."),CONFIG_FILE));
}
else
{