From 6e7583835517892055ea3bd267ffe39a5bf42dcf Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 5 Nov 2009 07:01:07 +0000 Subject: [PATCH] Updated class ldap -Displays attribute list in case of an error, id display_errors is true. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14748 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_ldap.inc | 39 ++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index 9b968fd9d..bf5385e01 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -557,6 +557,29 @@ class LDAP{ } } + function makeReadableErrors($error,$attrs) + { + global $config; + + if($this->success()) return(""); + + $str = ""; + if(preg_match("/^objectClass: value #([0-9]*) invalid per syntax$/", $this->get_additional_error())){ + $oc = preg_replace("/^objectClass: value #([0-9]*) invalid per syntax$/","\\1", $this->get_additional_error()); + if(isset($attrs['objectClass'][$oc])){ + $str.= " - objectClass: ".$attrs['objectClass'][$oc].""; + } + } + if($error == "Undefined attribute type"){ + $str = " - attribute: ".preg_replace("/:.*$/","",$this->get_additional_error()).""; + } + + if(is_object($config) && $config->get_cfg_value("displayerrors") == "true" && function_exists("print_a")){ + $str .= print_a($attrs,true); + } + + return($str); + } function modify($attrs) { @@ -564,14 +587,13 @@ class LDAP{ return (0); } if($this->hascon){ + + $attrs['objectClass'][0] = "Herb ert"; if ($this->reconnect) $this->connect(); $r = @ldap_modify($this->cid, LDAP::fix($this->basedn), $attrs); $this->error = @ldap_error($this->cid); - if(!$this->success() && preg_match("/^objectClass: value #([0-9]*) invalid per syntax$/", $this->get_additional_error())){ - $oc = preg_replace("/^objectClass: value #([0-9]*) invalid per syntax$/","\\1", $this->get_additional_error()); - if(isset($attrs['objectClass'][$oc])){ - $this->error.= " objectClass: ".$attrs['objectClass'][$oc].""; - } + if(!$this->success()){ + $this->error.= $this->makeReadableErrors($this->error,$attrs); } return($r ? $r : 0); }else{ @@ -586,11 +608,8 @@ class LDAP{ if ($this->reconnect) $this->connect(); $r = @ldap_add($this->cid, LDAP::fix($this->basedn), $attrs); $this->error = @ldap_error($this->cid); - if(!$this->success() && preg_match("/^objectClass: value #([0-9]*) invalid per syntax$/", $this->get_additional_error())){ - $oc = preg_replace("/^objectClass: value #([0-9]*) invalid per syntax$/","\\1", $this->get_additional_error()); - if(isset($attrs['objectClass'][$oc])){ - $this->error.= " objectClass: ".$attrs['objectClass'][$oc].""; - } + if(!$this->success()){ + $this->error.= $this->makeReadableErrors($this->error,$attrs); } return($r ? $r : 0); }else{ -- 2.30.2