From f7f871dada1deaa0ad2be925406e9e7622e1c056 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 12 Jan 2006 15:27:59 +0000 Subject: [PATCH] Updated ldap->search for speed improvements git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2470 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/addons/addressbook/class_addressbook.inc | 4 ++-- plugins/admin/systems/class_workstationGeneric.inc | 2 +- plugins/generic/references/class_reference.inc | 2 +- plugins/gofax/blocklists/class_blocklistManagement.inc | 5 ++--- plugins/personal/connectivity/class_kolabAccount.inc | 4 ++-- plugins/personal/environment/class_hotplugDialog.inc | 2 +- plugins/personal/mail/class_mailAccount.inc | 6 ++---- plugins/personal/samba/class_sambaAccount.inc | 5 ++--- 8 files changed, 13 insertions(+), 17 deletions(-) diff --git a/plugins/addons/addressbook/class_addressbook.inc b/plugins/addons/addressbook/class_addressbook.inc index 4ffa68c75..225631cf5 100644 --- a/plugins/addons/addressbook/class_addressbook.inc +++ b/plugins/addons/addressbook/class_addressbook.inc @@ -316,11 +316,11 @@ class addressbook extends plugin foreach ($bases as $base){ $ldap->cd ($base); if ($phonefilter['object_type'] == '*'){ - $ldap->search ("(&(objectClass=person)$filter(!(objectClass=gosaUserTemplate))(!(uid=*$))". + $ldap->search ("(&(objectClass=person)$filter(!(objectClass=gosaUserTemplate))(!(uid=*$))". //array "(|(uid=$s)(homePhone=$s)(telephoneNumber=$s)". "(facsimileTelephoneNumber=$s)(mobile=$s)(givenName=$s)(sn=$s)))", array("sn", "givenName", "telephoneNumber", "facsimileTelephoneNumber", "mobile", "homePhone", "uid", "mail", "cn")); } else { - $ldap->search ("(&$filter(!(uid=*$))(!(objectClass=gosaUserTemplate))". + $ldap->search ("(&$filter(!(uid=*$))(!(objectClass=gosaUserTemplate))". //array "(".$phonefilter['object_type']."=$s))", array("sn", "givenName", "telephoneNumber", "facsimileTelephoneNumber", "mobile", "homePhone", "uid", "mail", "cn")); } diff --git a/plugins/admin/systems/class_workstationGeneric.inc b/plugins/admin/systems/class_workstationGeneric.inc index 6ee0d68f5..eb4f05fba 100644 --- a/plugins/admin/systems/class_workstationGeneric.inc +++ b/plugins/admin/systems/class_workstationGeneric.inc @@ -52,7 +52,7 @@ class workgeneric extends plugin /* Load available modes */ $ldap= $this->config->get_ldap_link(); $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(objectClass=gotoInstallProfile)"); + $ldap->search ("(objectClass=gotoInstallProfile)",array("cn")); while ($attrs= $ldap->fetch()){ $this->modes[]= $attrs["cn"][0]; } diff --git a/plugins/generic/references/class_reference.inc b/plugins/generic/references/class_reference.inc index 70a4f6b69..43d945dbe 100644 --- a/plugins/generic/references/class_reference.inc +++ b/plugins/generic/references/class_reference.inc @@ -82,7 +82,7 @@ class reference extends plugin { $ldap= $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); - $ldap->search("(|(member=".$this->dn.")(memberUid=".$this->uid."))"); + $ldap->search("(|(member=".$this->dn.")(memberUid=".$this->uid."))",array("memberUid","member","cn","description","objectClass")); $cycle= array("F5F5F5", "ECECEC"); $id= 0; diff --git a/plugins/gofax/blocklists/class_blocklistManagement.inc b/plugins/gofax/blocklists/class_blocklistManagement.inc index 10f053541..5f6025c4b 100644 --- a/plugins/gofax/blocklists/class_blocklistManagement.inc +++ b/plugins/gofax/blocklists/class_blocklistManagement.inc @@ -533,8 +533,7 @@ class blocklist extends plugin if ($this->dn == 'new'){ $ldap= $this->config->get_ldap_link(); $ldap->cd ("ou=gofax,ou=systems,".$this->config->current["BASE"]); - $ldap->search ("(&(|(objectClass=goFaxSBlock)(objectClass=goFaxRBlock))". - "(cn=".$this->cn."))", array("cn")); + $ldap->search ("(&(|(objectClass=goFaxSBlock)(objectClass=goFaxRBlock))(cn=".$this->cn."))", array("cn")); if ($ldap->count() != 0){ $message[]= _("Specified name is already used."); } @@ -571,7 +570,7 @@ class blocklist extends plugin /* Write back to ldap */ $ldap= $this->config->get_ldap_link(); $ldap->cd($ldap->getParentDir($this->dn)); - $ldap->search("cn=$this->cn"); + $ldap->search("cn=$this->cn",array("cn")); $a= $ldap->fetch(); if (count($a)){ if (!isset($this->attrs["$type"."list"])){ diff --git a/plugins/personal/connectivity/class_kolabAccount.inc b/plugins/personal/connectivity/class_kolabAccount.inc index 7949f0324..7596ec118 100644 --- a/plugins/personal/connectivity/class_kolabAccount.inc +++ b/plugins/personal/connectivity/class_kolabAccount.inc @@ -108,7 +108,7 @@ class kolabAccount extends plugin $ldap= $this->config->get_ldap_link(); $ldap->cd ($this->config->current['BASE']); - $ldap->search('(mail='.$address.')'); + $ldap->search('(mail='.$address.')',array("mail")); if ($ldap->count() == 0){ print_red (_("The mail address you're trying to add is no primary mail address of an existing user.")); } else { @@ -254,7 +254,7 @@ class kolabAccount extends plugin $ldap= $this->config->get_ldap_link(); $ldap->cd ($this->config->current['BASE']); - $ldap->search('(mail='.$address.')'); + $ldap->search('(mail='.$address.')',array("mail")); if ($ldap->count() == 0){ $message[]= sprintf(_("There's no mail user with address '%s' for your invitation policy!"), $address); } else { diff --git a/plugins/personal/environment/class_hotplugDialog.inc b/plugins/personal/environment/class_hotplugDialog.inc index 22b11d988..dc9fbfdf2 100644 --- a/plugins/personal/environment/class_hotplugDialog.inc +++ b/plugins/personal/environment/class_hotplugDialog.inc @@ -118,7 +118,7 @@ class hotplugDialog extends plugin } $ldap = $this->config->get_ldap_link(); - $ldap->search("(&(objectClass=gotoEnvironment)(gotoHotplugDevice=".$this->HOT_name."*))"); + $ldap->search("(&(objectClass=gotoEnvironment)(gotoHotplugDevice=".$this->HOT_name."*))",array("gotoHotplugDevice")); if($ldap->count()){ $message[]=_("An Entry with this name already exists."); } diff --git a/plugins/personal/mail/class_mailAccount.inc b/plugins/personal/mail/class_mailAccount.inc index 72c33376c..1f02e8c1e 100644 --- a/plugins/personal/mail/class_mailAccount.inc +++ b/plugins/personal/mail/class_mailAccount.inc @@ -714,8 +714,7 @@ class mailAccount extends plugin } } $ldap->cd($this->config->current['BASE']); - $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=". - $this->mail."))(!(uid=".$this->uid."))(!(cn=".$this->uid.")))", array("uid")); + $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=".$this->mail."))(!(uid=".$this->uid."))(!(cn=".$this->uid.")))", array("uid")); if ($ldap->count() != 0){ $message[]= _("The primary address you've entered is already in use."); } @@ -802,8 +801,7 @@ class mailAccount extends plugin /* Is this address already assigned in LDAP? */ $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)". - "(gosaMailAlternateAddress=$address)))", array("uid")); + $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)"."(gosaMailAlternateAddress=$address)))", array("uid")); if ($ldap->count() > 0){ $attrs= $ldap->fetch (); diff --git a/plugins/personal/samba/class_sambaAccount.inc b/plugins/personal/samba/class_sambaAccount.inc index 0dc554579..5a8cab055 100644 --- a/plugins/personal/samba/class_sambaAccount.inc +++ b/plugins/personal/samba/class_sambaAccount.inc @@ -118,7 +118,7 @@ class sambaAccount extends plugin $this->SID= preg_replace ("/-[^-]+$/", "", $this->sambaSID); $ldap= $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); - $ldap->search ("(&(objectClass=sambaDomain)(sambaSID=$this->SID))"); + $ldap->search ("(&(objectClass=sambaDomain)(sambaSID=$this->SID))",array("sambaAlgorithmicRidBase","sambaDomainName")); if ($ldap->count() != 0){ $attrs= $ldap->fetch(); $this->ridBase= $attrs['sambaAlgorithmicRidBase'][0]; @@ -860,8 +860,7 @@ class sambaAccount extends plugin /* Check for users primary group */ $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", - array("cn")); + $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn")); if ($ldap->count() != 1){ print_red(_("Warning: Can't identify users primary group - no conversion to a samba group possible!")); } else { -- 2.30.2