Code

Replaced in_array calls for gosa-plugins
[gosa.git] / gosa-plugins / mit-krb5 / admin / systems / services / kerberos / class_password-methods-MIT.inc
index 322511f1fe521a74defce624a85fd53291f3175f..0a65aea84f7891155dc8b559a919d3d89a5a27e7 100644 (file)
@@ -88,6 +88,21 @@ class passwordMethodMIT extends passwordMethod
   var $POLICY                   = "_none_";
   var $POLICIES                 = array(); // Policies provided by the corrently selected realm/server
 
+  public function is_locked($config,$dn = "")
+  {
+    return(FALSE);
+  }
+
+  public function lock_account($config,$dn = "")
+  {
+    return(FALSE);
+  }
+
+  public function unlock_account($config,$dn = "")
+  {
+    return(FALSE);
+  }
+
   public function __construct(&$config,$dn = "new")  
   {
     $this->config= $config;
@@ -96,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;
     }  
 
@@ -269,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);
     }
@@ -322,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);  
@@ -337,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;
@@ -389,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";
@@ -639,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;
       }