From 8e41425c93cd83ec484adf93d3ee91e22b4b2880 Mon Sep 17 00:00:00 2001 From: Rudolf Mayerhofer Date: Fri, 21 Sep 2012 12:00:52 +0200 Subject: make use of adLDAP 4.0.4 in AD backend The new version of adLDAP improves the speed in handling recursive group memberships dramatically --- inc/adLDAP/collections/adLDAPCollection.php | 137 +++++++++++++++++++++ .../collections/adLDAPComputerCollection.php | 46 +++++++ inc/adLDAP/collections/adLDAPContactCollection.php | 46 +++++++ inc/adLDAP/collections/adLDAPGroupCollection.php | 46 +++++++ inc/adLDAP/collections/adLDAPUserCollection.php | 46 +++++++ 5 files changed, 321 insertions(+) create mode 100644 inc/adLDAP/collections/adLDAPCollection.php create mode 100644 inc/adLDAP/collections/adLDAPComputerCollection.php create mode 100644 inc/adLDAP/collections/adLDAPContactCollection.php create mode 100644 inc/adLDAP/collections/adLDAPGroupCollection.php create mode 100644 inc/adLDAP/collections/adLDAPUserCollection.php (limited to 'inc/adLDAP/collections') diff --git a/inc/adLDAP/collections/adLDAPCollection.php b/inc/adLDAP/collections/adLDAPCollection.php new file mode 100644 index 000000000..c0a2eb2fa --- /dev/null +++ b/inc/adLDAP/collections/adLDAPCollection.php @@ -0,0 +1,137 @@ +setInfo($info); + $this->adldap = $adldap; + } + + /** + * Set the raw info array from Active Directory + * + * @param array $info + */ + public function setInfo(array $info) + { + if ($this->info && sizeof($info) >= 1) { + unset($this->info); + } + $this->info = $info; + } + + /** + * Magic get method to retrieve data from the raw array in a formatted way + * + * @param string $attribute + * @return mixed + */ + public function __get($attribute) + { + if (isset($this->info[0]) && is_array($this->info[0])) { + foreach ($this->info[0] as $keyAttr => $valueAttr) { + if (strtolower($keyAttr) == strtolower($attribute)) { + if ($this->info[0][strtolower($attribute)]['count'] == 1) { + return $this->info[0][strtolower($attribute)][0]; + } + else { + $array = array(); + foreach ($this->info[0][strtolower($attribute)] as $key => $value) { + if ((string)$key != 'count') { + $array[$key] = $value; + } + } + return $array; + } + } + } + } + else { + return NULL; + } + } + + /** + * Magic set method to update an attribute + * + * @param string $attribute + * @param string $value + * @return bool + */ + abstract public function __set($attribute, $value); + + /** + * Magic isset method to check for the existence of an attribute + * + * @param string $attribute + * @return bool + */ + public function __isset($attribute) { + if (isset($this->info[0]) && is_array($this->info[0])) { + foreach ($this->info[0] as $keyAttr => $valueAttr) { + if (strtolower($keyAttr) == strtolower($attribute)) { + return true; + } + } + } + return false; + } +} +?> diff --git a/inc/adLDAP/collections/adLDAPComputerCollection.php b/inc/adLDAP/collections/adLDAPComputerCollection.php new file mode 100644 index 000000000..4f11d8f41 --- /dev/null +++ b/inc/adLDAP/collections/adLDAPComputerCollection.php @@ -0,0 +1,46 @@ + diff --git a/inc/adLDAP/collections/adLDAPContactCollection.php b/inc/adLDAP/collections/adLDAPContactCollection.php new file mode 100644 index 000000000..d42fe6d4c --- /dev/null +++ b/inc/adLDAP/collections/adLDAPContactCollection.php @@ -0,0 +1,46 @@ + diff --git a/inc/adLDAP/collections/adLDAPGroupCollection.php b/inc/adLDAP/collections/adLDAPGroupCollection.php new file mode 100644 index 000000000..cff12fc20 --- /dev/null +++ b/inc/adLDAP/collections/adLDAPGroupCollection.php @@ -0,0 +1,46 @@ + diff --git a/inc/adLDAP/collections/adLDAPUserCollection.php b/inc/adLDAP/collections/adLDAPUserCollection.php new file mode 100644 index 000000000..801d90296 --- /dev/null +++ b/inc/adLDAP/collections/adLDAPUserCollection.php @@ -0,0 +1,46 @@ + -- cgit v1.2.3