Code

Updated Placeholder handling, fixed problems with UPPER/lowercase handling
[gosa.git] / gosa-core / include / functions.inc
index cc3451475f5b47c63bba12626804be65688f2b87..22670325a322509c57f3c9a8fed9e99d8d96f171 100644 (file)
@@ -701,17 +701,27 @@ function ldap_expired_account($config, $userdn, $uid)
 
     // Fetch required attributes
     foreach(array('shadowExpire','shadowLastChange','shadowMax','shadowMin',
-                'shadowInactive','shadowWarning') as $attr){
+                'shadowInactive','shadowWarning','sambaKickoffTime') as $attr){
         $$attr = (isset($attrs[$attr][0]))? $attrs[$attr][0] : null;
     }
 
 
+    // Check if the account has reached its kick off limitations.
+    // ---------------------------------------------------------
+    // Once the accout reaches the kick off limit it has expired.
+    if($sambaKickoffTime !== null){
+        if(time() >= $sambaKickoffTime){
+            return(POSIX_ACCOUNT_EXPIRED);
+        }
+    }
+
+
     // Check if the account has expired.
     // ---------------------------------
     // An account is locked/expired once its expiration date has reached (shadowExpire).
     // If the optional attribute (shadowInactive) is set, we've to postpone
     //  the account expiration by the amount of days specified in (shadowInactive).
-    if($shadowExpire != null && $shadowExpire >= $current){
+    if($shadowExpire != null && $shadowExpire <= $current){
 
         // The account seems to be expired, but we've to check 'shadowInactive' additionally.
         // ShadowInactive specifies an amount of days we've to reprieve the user.
@@ -1440,7 +1450,9 @@ function get_ou($class,$name)
     global $config;
 
     if(!$config->configRegistry->propertyExists($class,$name)){
-        trigger_error("No department mapping found for type ".$name);
+        if($config->boolValueIsTrue("core","developmentMode")){
+            trigger_error("No department mapping found for type ".$name);
+        }
         return "";
     }
 
@@ -3613,7 +3625,7 @@ function detectLdapSpecialCharHandling()
     // In the DN we've to use escaped characters, but the object name (o)
     //  has the be un-escaped.
     $name = 'GOsaLdapEncoding_,_"_(_)_+_/';
-    $dnName = 'GOsaLdapEncoding_\,_\"_(_)_\+_\/';
+    $dnName = 'GOsaLdapEncoding_\,_\"_(_)_\+_/';
    
     // Prapare name to be useable in filters
     $fixed= normalizeLdap(str_replace('\\\\', '\\\\\\', $name));
@@ -3705,11 +3717,14 @@ function fillReplacements($str, $attrs, $shellArg = FALSE, $default = "")
     }
     krsort($hits);
 
+    // Add lower case placeholders to avoid errors
+    foreach($attrs as $key => $attr) $attrs[strtolower($key)] = $attr;
+
     // Replace the placeholder in the given string now.
     foreach($hits as $match){
 
         // Avoid errors about undefined index.
-        $name = $match[2];
+        $name = strtolower($match[2]);
         if(!isset($attrs[$name])) $attrs[$name] = $default;
 
         // Calculate the replacement
@@ -3767,10 +3782,11 @@ function gen_uids($rule, $attributes)
         if(!isset($match[5])){
             $replacements[$match[0]][] = $attributes[$match[2]];
     
-        // Start given but no end, so just add a simple character
+        // Start given but no end, so just add a single character
         }elseif(!isset($match[7])){
             if(isset($attributes[$match[2]][$match[5]])){
-                $replacements[$match[0]][] = $attributes[$match[2]][$match[5]];
+                $tmp = " ".$attributes[$match[2]];
+                $replacements[$match[0]][] = trim($tmp[$match[5]]);
             }
 
         // Add all values in range
@@ -3778,8 +3794,9 @@ function gen_uids($rule, $attributes)
             $str = "";
             for($i=$match[5]; $i<= $match[7]; $i++){
                 if(isset($attributes[$match[2]][$i])){
-                    $str .= $attributes[$match[2]][$i];
-                    $replacements[$match[0]][] = $str;
+                    $tmp = " ".$attributes[$match[2]];
+                    $str .= $tmp[$i];
+                    $replacements[$match[0]][] = trim($str);
                 }
             }
         }