Code

Cache password methods
[gosa.git] / gosa-core / include / class_gosaSupportDaemon.inc
index 503b8f0cfd3d9745bda6a7ffb1dae3b843f3f907..774d0e633190eeedfd8e15c86366e677de28dd06 100644 (file)
@@ -1272,14 +1272,72 @@ class gosaSupportDaemon
       "<header>gosa_krb5_get_principal</header>".
       "<principal>".$name."</principal>".
       "<source>GOSA</source>".
-      "<target>GOSA</target>".
+      "<target>".$server."</target>".
       "</xml>";
 
     return($this->_send($xml_msg,TRUE));
   }
 
 
-  /*! \brief  Creates/Updates a given principal with a set of configuration settings.
+  /*! \brief  Creates a given principal with a set of configuration settings.
+              For a list of configurable attributes have a look at 'krb5_get_principal()'.
+              (Uses the GOsa support daemon instead of the ldap database.)
+      @pram   String The name of the principal to update. (e.g. peter@EXAMPLE.DE)
+      @return Boolean   TRUE on success else FALSE. 
+   */
+  public function krb5_add_principal($server,$name,$values)
+  {
+    $ret = FALSE;  
+
+    /* Check if the given name is a valid request value 
+     */
+    if(!is_string($name) || empty($name)){
+      trigger_error("The given principal name is not of type string or it is empty.");
+      return($ret);
+    }
+    if(!is_array($values) || !count($values)){
+      trigger_error("No valid update settings given. The parameter must be of type array and must contain at least one entry");
+      return($ret);
+    }
+
+    /* Check if the given server is a valid mac address
+     */
+    if(!tests::is_mac($server)){
+      trigger_error("The given server address '".$server."' is invalid, it must be a valid mac address");
+      return($ret);
+    }
+
+    $attrs = "";
+    foreach($values as $key => $value){
+      if(empty($key) || is_numeric($key)){
+        trigger_error("Invalid configuration attribute given '".$key."=".$value."'.");
+        return($ret);
+      }
+      if(is_array($value)){
+        foreach($value as $val){
+          $attrs.= "<$key>$val</$key>\n";
+        }
+      }else{
+        $attrs.= "<$key>$value</$key>\n";
+      }
+    }
+
+    /* Prepare request event 
+     */ 
+    $xml_msg = 
+      "<xml>".
+      "<header>gosa_krb5_create_principal</header>".
+      "<principal>".$name."</principal>".
+      $attrs.
+      "<source>GOSA</source>".
+      "<target>".$server."</target>".
+      "</xml>";
+
+    return($this->_send($xml_msg,TRUE) == TRUE && !$this->is_error());
+  }
+
+
+  /*! \brief  Updates a given principal with a set of configuration settings.
               For a list of configurable attributes have a look at 'krb5_get_principal()'.
               (Uses the GOsa support daemon instead of the ldap database.)
       @pram   String The name of the principal to update. (e.g. peter@EXAMPLE.DE)
@@ -1308,12 +1366,18 @@ class gosaSupportDaemon
     }
 
     $attrs = "";
-    foreach($values as $name => $value){
-      if(empty($name) || is_numeric($name)){
-        trigger_error("Invalid configuration attribute given '".$name."=".$value."'.");
+    foreach($values as $key => $value){
+      if(empty($key) || is_numeric($key)){
+        trigger_error("Invalid configuration attribute given '".$key."=".$value."'.");
         return($ret);
       }
-      $attrs = "<$name>$value</$name>\n";
+      if(is_array($value)){
+        foreach($value as $val){
+          $attrs.= "<$key>$val</$key>\n";
+        }
+      }else{
+        $attrs.= "<$key>$value</$key>\n";
+      }
     }
 
     /* Prepare request event 
@@ -1324,7 +1388,7 @@ class gosaSupportDaemon
       "<principal>".$name."</principal>".
       $attrs.
       "<source>GOSA</source>".
-      "<target>GOSA</target>".
+      "<target>".$server."</target>".
       "</xml>";
 
     return($this->_send($xml_msg,TRUE) == TRUE && !$this->is_error());
@@ -1361,7 +1425,7 @@ class gosaSupportDaemon
       "<header>gosa_krb5_del_principal</header>".
       "<principal>".$name."</principal>".
       "<source>GOSA</source>".
-      "<target>GOSA</target>".
+      "<target>".$server."</target>".
       "</xml>";
     
     return($this->_send($xml_msg,TRUE) == TRUE && !$this->is_error());
@@ -1602,7 +1666,7 @@ class gosaSupportDaemon
       "<header>gosa_krb5_del_policy</header>".
       "<policy>".$name."</policy>".
       "<source>GOSA</source>".
-      "<target>GOSA</target>".
+      "<target>".$server."</target>".
       "</xml>";
     return($this->_send($xml_msg,TRUE) == TRUE && !$this->is_error());
   }