Code

Updated class password-method
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Oct 2010 15:20:55 +0000 (15:20 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Oct 2010 15:20:55 +0000 (15:20 +0000)
-Do not write sambaHashes while samba hashing is disabled

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20038 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/password-methods/class_password-methods.inc

index 695f32e7171783c82c60de123268eb7b903ce822..4e5f38f83117bf2f41793fb0d4b9a721a28c1a46 100644 (file)
@@ -106,8 +106,13 @@ class passwordMethod
 
             /* Lock entry */
             $userPassword = preg_replace("/(^[^\}]+\})(.*$)/","\\1!\\2",$userPassword);
-            $sambaLMPassword = preg_replace("/^[!]*(.*$)/","!\\1",$sambaLMPassword);
-            $sambaNTPassword = preg_replace("/^[!]*(.*$)/","!\\1",$sambaNTPassword);
+
+            // Only lock samba hashes if samba passwords are enabled
+            $smbPasswdEnabled = trim($config->get_cfg_value('core','sambaHashHook')) == "";
+            if($smbPasswdEnabled){
+                $sambaLMPassword = preg_replace("/^[!]*(.*$)/","!\\1",$sambaLMPassword);
+                $sambaNTPassword = preg_replace("/^[!]*(.*$)/","!\\1",$sambaNTPassword);
+            }
 
             // Call external lock hook
             $res = $ldap->cat($dn);
@@ -122,12 +127,16 @@ class passwordMethod
 
             // Update the ldap entry
             $ldap->cd($dn);
-            $ldap->modify(
-                    array(
-                        "userPassword" => $userPassword,
-                        "sambaLMPassword" => $sambaLMPassword,
-                        "sambaNTPassword" => $sambaNTPassword));
+            $attrs = array();
+            $attrs['userPassword'] = $userPassword;
+    
+            // Updated samba hashes if samba hashing is enabled
+            if($smbPasswdEnabled){
+                $attrs['sambaLMPassword'] = $sambaLMPassword;
+                $attrs['sambaNTPassword'] = $sambaNTPassword;
+            }
 
+            $ldap->modify($attrs);
             if($ldap->success()){
 
                 // Call the password post-lock hook, if defined.
@@ -174,9 +183,15 @@ class passwordMethod
             }     
 
             /* Lock entry */
+
             $userPassword = preg_replace("/(^[^\}]+\})!(.*$)/","\\1\\2",$userPassword);
-            $sambaLMPassword = preg_replace("/^[!]*(.*$)/","\\1",$sambaLMPassword);
-            $sambaNTPassword = preg_replace("/^[!]*(.*$)/","\\1",$sambaNTPassword);
+
+            // Update samba hashes only if its enabled.
+            $smbPasswdEnabled = trim($config->get_cfg_value('core','sambaHashHook')) == "";
+            if($smbPasswdEnabled){
+                $sambaLMPassword = preg_replace("/^[!]*(.*$)/","\\1",$sambaLMPassword);
+                $sambaNTPassword = preg_replace("/^[!]*(.*$)/","\\1",$sambaNTPassword);
+            }
 
             // Call external lock hook
             $res = $ldap->cat($dn);
@@ -191,11 +206,19 @@ class passwordMethod
 
             // Lock the account by modifying the password hash. 
             $ldap->cd($dn);
-            $ldap->modify(
-                    array(
-                        "userPassword" => $userPassword,
-                        "sambaLMPassword" => $sambaLMPassword,
-                        "sambaNTPassword" => $sambaNTPassword));
+
+            // Update the ldap entry
+            $attrs = array();
+            $attrs['userPassword'] = $userPassword;
+
+            // Updated samba hashes if samba hashing is enabled
+            if($smbPasswdEnabled){
+                $attrs['sambaLMPassword'] = $sambaLMPassword;
+                $attrs['sambaNTPassword'] = $sambaNTPassword;
+            }
+
+            $ldap->modify($attrs);
+
             if($ldap->success()){
 
                 // Call the password post-lock hook, if defined.