Code

Replace placeholders in samba templates
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 11 Jun 2008 13:13:37 +0000 (13:13 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 11 Jun 2008 13:13:37 +0000 (13:13 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11287 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/samba/personal/samba/class_sambaAccount.inc

index a5fec4f2cac75a5388cc6a82a2cd96e20ca834ab..f17dada9b1236ad9ab486442d06deb7b6183ae1e 100644 (file)
@@ -1122,14 +1122,29 @@ class sambaAccount extends plugin
   function adapt_from_template($dn, $skip= array())
   {
     plugin::adapt_from_template($dn, $skip);
+
+
     $this->sambaSID= "";
     $this->sambaPrimaryGroupSID= "";
 
-      /* Fill mungedDial field */
+    /* Fill mungedDial field */
     if ($this->samba3 && isset($this->attrs['sambaMungedDial']) && !in_array('sambaMungedDial', $skip)){
       $this->mungedObject->load($this->sambaMungedDial);
     }
 
+    /* Adapt munged attributes */
+    foreach($this->ctxattributes as $attr){
+      if(isset($this->mungedObject->ctx[$attr]))
+        $val = $this->mungedObject->ctx[$attr];
+
+      foreach (array("sn", "givenName", "uid") as $repl){
+        if (preg_match("/%$repl/i", $val)){
+          $val= preg_replace ("/%$repl/i", $this->parent->$repl, $val);
+        }
+      }
+      $this->mungedObject->ctx[$attr] = $val;
+    }
+
     /* Password expiery */
     if(isset($this->attrs['sambaPwdMustChange']) &&
         $this->attrs['sambaPwdMustChange'][0] != 0 && !in_array('sambaPwdMustChange', $skip)){