From 3728c5b39b08c12f926f0cb1a6f22674eb67ce52 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 23 Apr 2008 08:52:13 +0000 Subject: [PATCH] Added "setter" and "getter" function for krb si functionality. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10636 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_gosaSupportDaemon.inc | 260 +++++++++++++++++- 1 file changed, 251 insertions(+), 9 deletions(-) diff --git a/gosa-core/include/class_gosaSupportDaemon.inc b/gosa-core/include/class_gosaSupportDaemon.inc index c383f03bb..515ab63f8 100644 --- a/gosa-core/include/class_gosaSupportDaemon.inc +++ b/gosa-core/include/class_gosaSupportDaemon.inc @@ -1185,17 +1185,259 @@ class gosaSupportDaemon } -static function ping($target) -{ - if (tests::is_mac($target)){ - /* Get communication object */ - $d= new gosaSupportDaemon(TRUE,0.5); - $answer= $d->_send("
gosa_ping
GOSA$target
", TRUE); - return (count($answer) ? TRUE:FALSE); + static function ping($target) + { + if (tests::is_mac($target)){ + /* Get communication object */ + $d= new gosaSupportDaemon(TRUE,0.5); + $answer= $d->_send("
gosa_ping
GOSA$target
", TRUE); + return (count($answer) ? TRUE:FALSE); + } + return (FALSE); } - return (FALSE); -} + + + /*! \brief Returns a list of all configured principals. + (Uses the GOsa support daemon instead of the ldap database.) + @return Array A list containing the names of all configured principals. + */ + public function krb5_list_principals() + { + $xml_msg = "
krb5_list_principals
GOSAGOSA
"; + return($this->_send($xml_msg,TRUE)); + } + + + /*! \brief Returns the configuration settings for a given principal name. + (Uses the GOsa support daemon instead of the ldap database.) + @pram String The name of the requested principal. (e.g. peter@EXAMPLE.DE) + @return Array A list containing the names of all configured principals. + */ + public function krb5_get_principal($name) + { + $ret = array(); + + /* 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); + } + + /* Prepare request event + */ + $xml_msg = + "". + "
krb5_get_principal
". + "".$name."". + "GOSA". + "GOSA". + "
"; + + return($this->_send($xml_msg,TRUE)); + } + + + /*! \brief Creates/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) + @return Boolean TRUE on success else FALSE. + */ + public function krb5_set_principal($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); + } + + $attrs = ""; + foreach($values as $name => $value){ + if(empty($name) || is_numeric($name)){ + trigger_error("Invalid configuration attribute given '".$name."=".$value."'."); + return($ret); + } + $attrs = "<$name>$value\n"; + } + + /* Prepare request event + */ + $xml_msg = + "". + "
krb5_set_principal
". + "".$name."". + $attrs. + "GOSA". + "GOSA". + "
"; + + return($this->_send($xml_msg,TRUE)); + } + + + /*! \brief Removes the given principal. + (Uses the GOsa support daemon instead of the ldap database.) + @pram String The name of the principal. (e.g. peter@EXAMPLE.DE) + @return Boollean TRUE on success else FALSE + */ + public function krb5_del_principal($name) + { + $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); + } + + /* Prepare request event + */ + $xml_msg = + "". + "
krb5_del_principal
". + "".$name."". + "GOSA". + "GOSA". + "
"; + + + return($this->_send($xml_msg,TRUE)); + } + + + /*! \brief Returns a list of configured password policies. + (Uses the GOsa support daemon instead of the ldap database.) + @return Array A list of all configured password policies. + */ + public function krb5_list_policies() + { + $res = array(); + + /* Prepare request event + */ + $xml_msg = + "". + "
krb5_list_policies
". + "GOSA". + "GOSA". + "
"; + + return($this->_send($xml_msg,TRUE)); + } + + + /*! \brief Returns a list of configured password policies. + (Uses the GOsa support daemon instead of the ldap database.) + @return Array The policy settings for the given policy name. + */ + public function krb5_get_policy($name) + { + $res = array(); + + /* Check if the given name is a valid request value + */ + if(!is_string($name) || empty($name)){ + trigger_error("The given policy name is not of type string or it is empty."); + return($ret); + } + + /* Prepare request event + */ + $xml_msg = + "". + "
krb5_get_policy
". + "".$name."". + "GOSA". + "GOSA". + "
"; + + return($this->_send($xml_msg,TRUE)); + } + + + /*! \brief Creates/Updates a given policy with a set of configuration settings. + For a list of configurable attributes have a look at 'krb5_get_policy()'. + (Uses the GOsa support daemon instead of the ldap database.) + @pram String The name of the policy to update. + @return Boolean TRUE on success else FALSE. + */ + public function krb5_set_policy($name,$values) + { + $ret = FALSE; + + /* Check if the given name is a valid request value + */ + if(!is_string($name) || empty($name)){ + trigger_error("The given policy name is not of type string or it is empty."); + return($ret); + } + if(!is_array($values) || !count($values)){ + trigger_error("No valid policy settings given. The parameter must be of type array and must contain at least one entry"); + return($ret); + } + + /* Transform array into + */ + $attrs = ""; + foreach($values as $name => $value){ + if(empty($name) || is_numeric($name)){ + trigger_error("Invalid policy configuration attribute given '".$name."=".$value."'."); + return($ret); + } + $attrs = "<$name>$value\n"; + } + + /* Prepare request event + */ + $xml_msg = + "". + "
krb5_set_policy
". + "".$name."". + $attrs. + "GOSA". + "GOSA". + "
"; + + return($this->_send($xml_msg,TRUE)); + } + + + /*! \brief Removes the given password policy. + (Uses the GOsa support daemon instead of the ldap database.) + @return Boolean TRUE on success else FALSE + */ + public function krb5_del_policy($name) + { + $ret = FALSE; + + /* Check if the given name is a valid request value + */ + if(!is_string($name) || empty($name)){ + trigger_error("The given policy name is not of type string or it is empty."); + return($ret); + } + + /* Prepare request event + */ + $xml_msg = + "". + "
krb5_del_policy
". + "".$name."". + "GOSA". + "GOSA". + "
"; + return($this->_send($xml_msg,TRUE)); + } } -- 2.30.2