Code

Replaced in_array calls for gosa-plugins
[gosa.git] / gosa-plugins / mit-krb5 / admin / systems / services / kerberos / class_password-methods-MIT.inc
index ccf7082448f0bc4e82e7e132be71238d485d9e37..0a65aea84f7891155dc8b559a919d3d89a5a27e7 100644 (file)
@@ -111,7 +111,7 @@ class passwordMethodMIT extends passwordMethod
     /* No config object given, this may be the case 
        if there is only a is_available() request triggered.
      */
-    if(!is_object($config)){
+    if(!is_object($this->config)){
       return;
     }  
 
@@ -284,14 +284,16 @@ class passwordMethodMIT extends passwordMethod
     $cache = session::get("MIT_PRINCIPAL_CACHE");
     if(!isset($cache[$server])){
       $o = new gosaSupportDaemon();
-      $tmp = $o->krb5_list_principals($server);
-      if($o->is_error()){
-        $this->si_error     = TRUE;
-        $this->si_error_msg = sprintf(_("Cannot load principals from server '%s'!"),$server).":&nbsp;<br>".$o->get_error(); 
-        msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG);
-        return(array());
-      }else{
-        $cache[$server] = $tmp;
+      if($o->is_configured()){
+        $tmp = $o->krb5_list_principals($server);
+        if($o->is_error()){
+          $this->si_error     = TRUE;
+          $this->si_error_msg = sprintf(_("Cannot load principals from server '%s'!"),$server).":&nbsp;<br>".$o->get_error(); 
+          msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG);
+          return(array());
+        }else{
+          $cache[$server] = $tmp;
+        }
       }
       session::set("MIT_PRINCIPAL_CACHE",$cache);
     }
@@ -337,8 +339,19 @@ class passwordMethodMIT extends passwordMethod
    */ 
   public function is_available()
   {
+    global $config;
+  
+    /* No config object given, this may be the case 
+       if there is only a is_available() request triggered.
+     */
+    if(!is_object($config)){
+       return;
+    }
+
+
     $o = new gosaSupportDaemon(FALSE);
-    if(count($this->server_list) && $o->connect()){
+
+    if(count($this->server_list) && $o->connect() && $o->is_configured()){
       return TRUE; 
     }
     return(FALSE);  
@@ -352,7 +365,11 @@ class passwordMethodMIT extends passwordMethod
   public function generate_hash($pwd = "")
   {
     $mode= "kerberos";
-    if ($this->config->get_cfg_value("useSaslForKerberos") == "true"){
+
+    /* No config object given, this may be the case 
+       if there is only a is_available() request triggered.
+     */
+    if (is_object($this->config) && $this->config->get_cfg_value("useSaslForKerberos") == "true"){
       $mode= "sasl";
     }
     return "{".$mode."}".$this->attrs['uid'][0]."@".$this->goKrbRealm;
@@ -404,7 +421,11 @@ class passwordMethodMIT extends passwordMethod
   public function get_hash_name()
   {
     $mode= "kerberos";
-    if ($this->config->get_cfg_value("useSaslForKerberos") == "true"){
+
+    /* No config object given, this may be the case 
+       if there is only a is_available() request triggered.
+     */
+    if (is_object($this->config) && $this->config->get_cfg_value("useSaslForKerberos") == "true"){
       $mode= "sasl";
     }
     return "$mode";
@@ -654,7 +675,7 @@ class passwordMethodMIT extends passwordMethod
 
       /* Save principal changes */
       $o = new gosaSupportDaemon();
-      if(in_array($principal,$this->server_list[$server_name]['principals'])){
+      if(in_array_strict($principal,$this->server_list[$server_name]['principals'])){
         $this->is_new = FALSE;
       }