From: hickert Date: Wed, 30 Apr 2008 11:38:07 +0000 (+0000) Subject: Updated krb class X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=885cc4b0cf3c5ec1685fe68d3f76aab60d3974f9;p=gosa.git Updated krb class git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10741 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/heimdal/admin/systems/services/kerberos/class_password-methods-MIT.inc b/gosa-plugins/heimdal/admin/systems/services/kerberos/class_password-methods-MIT.inc index 4ea6d2999..4ce944634 100644 --- a/gosa-plugins/heimdal/admin/systems/services/kerberos/class_password-methods-MIT.inc +++ b/gosa-plugins/heimdal/admin/systems/services/kerberos/class_password-methods-MIT.inc @@ -1,7 +1,7 @@ parent_dn = $dn; /* No config object given, this may be the case - if there is only a is_available() request triggered. + if there is only a is_available() request triggered. */ if(!is_object($config)){ return; @@ -252,7 +112,7 @@ class passwordMethodMIT extends passwordMethod } /* Get a list of all kerberos servers, defined in ldap - and get a list of principals they are providing. + and get a list of principals they are providing. */ $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); @@ -285,6 +145,7 @@ class passwordMethodMIT extends passwordMethod /* Load object data from ldap && initialize this class */ + $this->is_new = TRUE; if($dn != "new" && $dn != ""){ $ldap = $this->config->get_ldap_link(); $ldap->cd($dn); @@ -308,6 +169,7 @@ class passwordMethodMIT extends passwordMethod /* Load principal */ $this->load_principal($this->server_list[$server]['macAddress'],$p_name); + $this->is_new = FALSE; } } } @@ -315,8 +177,8 @@ class passwordMethodMIT extends passwordMethod /*! \brief Load this plugin with the values of the given principal - @param String The macAddress of the kerberos server. - @param String The name of the principal to load. + @param String The macAddress of the kerberos server. + @param String The name of the principal to load. */ public function load_principal($server,$name) { @@ -386,18 +248,21 @@ class passwordMethodMIT extends passwordMethod session::set("MIT_POLICY_CACHE",array()); } $cache = session::get("MIT_POLICY_CACHE"); - if(!isset($cache[$server])){ + if(1 | !isset($cache[$server])){ $o = new gosaSupportDaemon(); $tmp = $o->krb5_list_policies($server); - $cache[$server] = $tmp; + $cache[$server] = array(); + $cache[$server]["_none_"] = _("none"); + foreach($tmp as $policy){ + $cache[$server][$policy] = $policy; + } + ksort($cache[$server]); session::set("MIT_POLICY_CACHE",$cache); } return($cache[$server]); } - - /*! \brief Check if this password method is useable. This is the case if there is a si server running and at least one server configured. kerberos support. @@ -528,7 +393,7 @@ class passwordMethodMIT extends passwordMethod $server_mac = $this->server_list[$server_name]['macAddress']; $this->POLICIES = $this->load_policies_for_server($server_mac); $smarty->assign("POLICIES" ,$this->POLICIES); - + foreach($this->values as $attr){ $smarty->assign($attr ,$this->$attr); } @@ -619,20 +484,49 @@ class passwordMethodMIT extends passwordMethod $attrs = $ldap->fetch(); if(isset($attrs['uid'][0])){ - $uid = $attrs['uid'][0]; - $name = $uid."@".strtoupper($realm); + /* Get servers mac */ + $server_name = $this->map['REALM_SERVER'][$this->goKrbRealm]; + $server_mac = $this->server_list[$server_name]['macAddress']; - foreach($this->attributes as $attr){ - $data[$attr] = array(); + $uid = $attrs['uid'][0]; + $principal = $uid."@".strtoupper($this->goKrbRealm); + $policy = $this->POLICY; + + /* Collect flags */ + $flags = array(); + $entry = array(); + foreach($this->flags as $flag){ + if($this->$flag){ + $flags[] = $flag; + } + } + if(count($flags)){ + $entry['ATTRIBUTES'] = $flags; } - echo "Save missing"; + /* Append other values */ + foreach($this->values as $attr){ + if($attr == "POLICY") continue; + $entry[$attr] = $this->$attr; + } + + /* Prepare entry to be saved */ + if($policy != "_none_"){ + $entry['POLICY'] = $policy; + } - print_a($data); - exit(); + /* Save principal changes */ + $o = new gosaSupportDaemon(); + if($this->is_new){ + $o->krb5_add_principal($server_mac,$principal,$entry); + }else{ + $o->krb5_set_principal($server_mac,$principal,$entry); + } + if($o->is_error()){ + msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG); + } } } } - // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>