From 268fbb384b1a1a1bbd3c4afefc55971ca8a38a4b Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 15 Sep 2006 09:47:47 +0000 Subject: [PATCH] Fixed new members in ogroups Fixed session problem for logger git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@4690 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_ldap.inc | 6 +- plugins/admin/ogroups/class_ogroup.inc | 90 +++++++++++++------------- 2 files changed, 50 insertions(+), 46 deletions(-) diff --git a/include/class_ldap.inc b/include/class_ldap.inc index c4768ee77..504a470d4 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -1154,9 +1154,11 @@ function gen_xls ($dn, $filter= "(objectClass=*)", $attributes= array('*'), $rec function log($string) { - $cfg= $_SESSION['config']; - if (isset($cfg->current['LDAPSTATS']) && preg_match('/true/i', $cfg->current['LDAPSTATS'])){ + if (isset($_SESSION['config'])){ + $cfg= $_SESSION['config']; + if (isset($cfg->current['LDAPSTATS']) && preg_match('/true/i', $cfg->current['LDAPSTATS'])){ syslog (LOG_INFO, $string); + } } } diff --git a/plugins/admin/ogroups/class_ogroup.inc b/plugins/admin/ogroups/class_ogroup.inc index 9715ac161..4552807b8 100644 --- a/plugins/admin/ogroups/class_ogroup.inc +++ b/plugins/admin/ogroups/class_ogroup.inc @@ -95,9 +95,10 @@ class ogroup extends plugin $this->reload(); } - function AddDelMembership($NewMember = false){ - + function AddDelMembership($NewMember = false) + { if($NewMember){ + $this->importMember($NewMember); $this->memberList[$NewMember]= $this->objcache[$NewMember]; $this->member[$NewMember]= $NewMember; unset ($this->objects[$NewMember]); @@ -440,48 +441,7 @@ class ogroup extends plugin /* Walk through all single member entry */ foreach($this->member as $dn){ - - /* The dn for the current member can't be resolved - it seams that this entry was removed - */ - /* Try to resolv the entry again, if it still fails, display error msg */ - $ldap->cat($dn, array("cn", "sn", "givenName", "ou", "description", "objectClass")); - - /* It has failed, add entry with type flag I (Invalid)*/ - if ($ldap->error != "Success"){ - $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".@LDAP::fix($dn),"type" => "I"); - - } else { - - /* Append this entry to our all object list */ - - /* Fetch object */ - $attrs= $ldap->fetch(); - - $type= $this->getObjectType($attrs); - $name= $this->getObjectName($attrs); - - if (isset($attrs["description"][0])){ - $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type"); - } elseif (isset($attrs["uid"][0])) { - $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["uid"][0]."]", "type" => "$type"); - } else { - $this->objcache[$attrs["dn"]]= array("text" => "$name", "type" => "$type"); - } - $this->objcache[$attrs["dn"]]['objectClass'] = $attrs['objectClass']; - if(isset($attrs['uid'])){ - $this->objcache[$attrs["dn"]]['uid'] = $attrs['uid']; - } - - /* Fill array */ - if (isset($attrs["description"][0])){ - $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type"); - } else { - $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type"); - } - - $this->memberList[$dn]= $this->objects[$attrs["dn"]]; - } + $this->importMember($dn); } uasort ($this->memberList, 'sort_list'); reset ($this->memberList); @@ -504,6 +464,48 @@ class ogroup extends plugin } + function importMember($dn) + { + $ldap= $this->config->get_ldap_link(); + + /* Try to resolv the entry again, if it still fails, display error msg */ + $ldap->cat($dn, array("cn", "sn", "givenName", "ou", "description", "objectClass")); + + /* It has failed, add entry with type flag I (Invalid)*/ + if ($ldap->error != "Success"){ + $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".@LDAP::fix($dn),"type" => "I"); + } else { + /* Append this entry to our all object list */ + + /* Fetch object */ + $attrs= $ldap->fetch(); + + $type= $this->getObjectType($attrs); + $name= $this->getObjectName($attrs); + + if (isset($attrs["description"][0])){ + $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type"); + } elseif (isset($attrs["uid"][0])) { + $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["uid"][0]."]", "type" => "$type"); + } else { + $this->objcache[$attrs["dn"]]= array("text" => "$name", "type" => "$type"); + } + $this->objcache[$attrs["dn"]]['objectClass'] = $attrs['objectClass']; + if(isset($attrs['uid'])){ + $this->objcache[$attrs["dn"]]['uid'] = $attrs['uid']; + } + + /* Fill array */ + if (isset($attrs["description"][0])){ + $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type"); + } else { + $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type"); + } + + $this->memberList[$dn]= $this->objects[$attrs["dn"]]; + } + } + function convert_list($input) { $temp= ""; -- 2.30.2