Projects
Kolab:16
php-kolab-net-ldap3
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 6
View file
php-kolab-net-ldap3.spec
Changed
@@ -24,7 +24,7 @@ %else Name: php-kolab-net-ldap3 %endif -Version: 1.0.7 +Version: 1.1.0 Release: 1%{?dist} Summary: Object oriented interface for searching and manipulating LDAP-entries Group: Development/Libraries @@ -71,6 +71,9 @@ %{_datadir}/%{php}/Net/LDAP3/Result.php %changelog +* Wed Jun 5 2019 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 1.1.0-1 +- Release of version 1.1.0 + * Wed Jun 20 2018 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 1.0.7-1 - Release of version 1.0.7
View file
debian.changelog
Changed
@@ -1,3 +1,9 @@ +php-net-ldap3 (1.1.0-1~kolab1) unstable; urgency=low + + * Release version 1.1.0 + + -- Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> Wed, 5 Jun 2019 15:27:46 +0100 + php-net-ldap3 (1.0.7-1~kolab1) unstable; urgency=low * Release version 1.0.7
View file
pear-Net-LDAP3-1.0.7.tar.gz/composer.json -> pear-Net-LDAP3-1.1.0.tar.gz/composer.json
Changed
@@ -2,7 +2,7 @@ "name": "kolab/net_ldap3", "description": "A successor of the PEAR:Net_LDAP2 module providing advanced functionality for accessing LDAP directories", "type": "library", - "version": "1.0.6", + "version": "1.0.7", "keywords": ["pear", "ldap", "vlv"], "homepage": "http://git.kolab.org/pear/Net_LDAP3/", "license": "GPL-3.0+",
View file
pear-Net-LDAP3-1.0.7.tar.gz/lib/Net/LDAP3.php -> pear-Net-LDAP3-1.1.0.tar.gz/lib/Net/LDAP3.php
Changed
@@ -41,6 +41,11 @@ */ class Net_LDAP3 { + const CONTROL_EFFECTIVE_RIGHTS = '1.3.6.1.4.1.42.2.27.9.5.2'; + const CONTROL_SORT_REQUEST = '1.2.840.113556.1.4.473'; + const CONTROL_VLV_REQUEST = '2.16.840.1.113730.3.4.9'; + const CONTROL_VLV_RESPONSE = '2.16.840.1.113730.3.4.10'; + public $conn; public $vlv_active = false; @@ -83,8 +88,9 @@ * 'root_dn' => 'dc=example,dc=org', */ protected $config = array( - 'sizelimit' => 0, - 'timelimit' => 0, + 'sizelimit' => 0, + 'timelimit' => 0, + 'config_root_dn' => 'cn=config', ); protected $debug_level = false; @@ -113,32 +119,29 @@ protected $_current_bind_dn; protected $_current_bind_pw; protected $_current_host; - protected $_supported_control = array(); + protected $_metadata; protected $_vlv_indexes_and_searches; + /** * Constructor * - * @param array $config Configuration parameters that have not already - * been initialized. For configuration parameters - * that have in fact been set, use the config_set() - * method after initialization. + * @param array $config Configuration parameters. After initialization use + * the config_set() method. */ public function __construct($config = array()) { if (!empty($config) && is_array($config)) { foreach ($config as $key => $value) { - if (empty($this->config[$key])) { - $setter = 'config_set_' . $key; - if (method_exists($this, $setter)) { - $this->$setter($value); - } - else if (isset($this->$key)) { - $this->$key = $value; - } - else { - $this->config[$key] = $value; - } + $setter = 'config_set_' . $key; + if (method_exists($this, $setter)) { + $this->$setter($value); + } + else if (isset($this->$key)) { + $this->$key = $value; + } + else { + $this->config[$key] = $value; } } } @@ -688,22 +691,16 @@ return true; } + /** + * Gets effective rights of an ldap entry + */ public function effective_rights($subject) { - $effective_rights_control_oid = "1.3.6.1.4.1.42.2.27.9.5.2"; - - $supported_controls = $this->supported_controls(); - - if (!in_array($effective_rights_control_oid, $supported_controls)) { + if (!in_array(self::CONTROL_EFFECTIVE_RIGHTS, $this->supported_controls())) { $this->_debug("LDAP: No getEffectiveRights control in supportedControls"); return false; } - $attributes = array( - 'attributeLevelRights' => array(), - 'entryLevelRights' => array(), - ); - $entry_dn = $this->entry_dn($subject); if (!$entry_dn) { @@ -720,6 +717,53 @@ $this->_debug("effective_rights for subject $subject resolves to entry dn $entry_dn"); + if (PHP_VERSION_ID >= 70300) { + // Note: This get_entry() have to request all attributes to be working + $result = $this->get_entry($entry_dn, array('*'), array( + array( + 'oid' => self::CONTROL_EFFECTIVE_RIGHTS, + 'value' => 'dn:' . $this->_current_bind_dn, + 'iscritical' => true, + ), + )); + + if (!empty($result)) { + $attributes = array( + 'dn' => $entry_dn, + 'attributeLevelRights' => array(), + 'entryLevelRights' => array(), + ); + + foreach (array('aclRights', 'attributeLevelRights', 'entryLevelRights') as $attr_name) { + if ($attr_value = $result[$attr_name]) { + switch ($attr_name) { + case 'aclRights': + $this->parse_aclrights($attributes, $attr_value); + break; + case 'attributeLevelRights': + $attributes[$attr_name] = $this->parse_attribute_level_rights($attr_value); + break; + case 'entryLevelRights': + $attributes[$attr_name] = $this->parse_entry_level_rights($attr_value); + break; + } + } + } + + $this->_debug("LDAP: Effective rights:" . var_export($attributes, true)); + + return $attributes; + } + + return false; + } + + // Use ldapsearch command + return $this->effective_rights_mozldap($entry_dn); + } + + protected function effective_rights_mozldap($entry_dn) + { $moz_ldapsearch = "/usr/lib64/mozldap/ldapsearch"; if (!is_file($moz_ldapsearch)) { $moz_ldapsearch = "/usr/lib/mozldap/ldapsearch"; @@ -729,7 +773,7 @@ } if (empty($moz_ldapsearch)) { - $this->_error("Mozilla LDAP C SDK binary ldapsearch not found, cannot get effective rights on subject $subject"); + $this->_error("Mozilla LDAP C SDK binary ldapsearch not found, cannot get effective rights"); return null; } @@ -754,33 +798,13 @@ if ($this->vendor_name() == "Oracle Corporation") { // For Oracle DSEE $command[] = "-J"; - $command[] = escapeshellarg( - implode( - ':', - Array( - $effective_rights_control_oid, // OID - 'true' // Criticality - ) - ) - ); + $command[] = escapeshellarg(self::CONTROL_EFFECTIVE_RIGHTS . ':true'); $command[] = "-c"; - $command[] = escapeshellarg( - 'dn:' . $this->_current_bind_dn - ); - + $command[] = escapeshellarg('dn:' . $this->_current_bind_dn); } else { // For 389 DS: $command[] = "-J"; - $command[] = escapeshellarg( - implode( - ':', - Array( - $effective_rights_control_oid, // OID - 'true', // Criticality - 'dn:' . $this->_current_bind_dn // User DN - ) - ) - ); + $command[] = escapeshellarg(self::CONTROL_EFFECTIVE_RIGHTS . ':true:dn:' . $this->_current_bind_dn); } // For both @@ -821,6 +845,12 @@ } } + $attributes = array( + 'dn' => $subject_dn, + 'attributeLevelRights' => array(), + 'entryLevelRights' => array(), + ); + if ($this->vendor_name() == "Oracle Corporation") { // Example for attribute level rights: // aclRights;attributeLevel;$attr:$right:$bool,$right:$bool @@ -828,20 +858,12 @@ // aclRights;entryLevel: add:1,delete:1,read:1,write:1,proxy:1 foreach ($lines as $line) { $line_components = explode(':', $line); - $attribute_name = explode(';', array_shift($line_components)); + $attribute_name = explode(';', array_shift($line_components)); - switch ($attribute_name[0]) { - case "aclRights": - $this->parse_aclrights($attributes, $line); - break; - case "dn": - $attributes[$attribute_name[0]] = trim(implode(';', $line_components)); - break; - default: - break; + if ($attribute_name[0] === "aclRights") { + $this->parse_aclrights($attributes, $line); } } - } else { foreach ($lines as $line) { $line_components = explode(':', $line); @@ -849,17 +871,12 @@ $attribute_value = trim(implode(':', $line_components)); switch ($attribute_name) { - case "attributeLevelRights": - $attributes[$attribute_name] = $this->parse_attribute_level_rights($attribute_value); - break; - case "dn": - $attributes[$attribute_name] = $attribute_value; - break; - case "entryLevelRights": - $attributes[$attribute_name] = $this->parse_entry_level_rights($attribute_value); - break; - default: - break; + case "attributeLevelRights": + $attributes[$attribute_name] = $this->parse_attribute_level_rights($attribute_value); + break; + case "entryLevelRights": + $attributes[$attribute_name] = $this->parse_entry_level_rights($attribute_value); + break; } } } @@ -970,18 +987,17 @@ public function get_entry_attributes($subject_dn, $attributes) { - // @TODO: use get_entry? - $result = $this->search($subject_dn, '(objectclass=*)', 'base', $attributes); + $result = $this->get_entry($subject_dn, $attributes); if (!$result) { return array(); } - $entries = $result->entries(true); - $entry_dn = key($entries); - $entry = $entries[$entry_dn]; + if (!in_array('*', $attributes) && !in_array('dn', $attributes)) { + unset($result['dn']); + } - return $entry; + return $result; } /** @@ -989,17 +1005,25 @@ * * @param string $dn Record identifier * @param array $attributes Attributes to return + * @param array $controls LDAP Controls * * @return array Hash array */ - public function get_entry($dn, $attributes = array()) + public function get_entry($dn, $attributes = array("*"), $controls = array()) { $rec = null; - if ($this->conn && $dn) { + if ($this->conn) { $this->_debug("C: Read [dn: $dn] [(objectclass=*)]"); - if ($ldap_result = @ldap_read($this->conn, $dn, '(objectclass=*)', $attributes)) { + if (!empty($controls)) { + $ldap_result = @ldap_read($this->conn, $dn, '(objectclass=*)', $attributes, 0, -1, -1, LDAP_DEREF_NEVER, $controls); + } + else { + $ldap_result = @ldap_read($this->conn, $dn, '(objectclass=*)', $attributes); + } + + if ($ldap_result) { $this->_debug("S: OK"); if ($entry = ldap_first_entry($this->conn, $ldap_result)) { @@ -1012,7 +1036,10 @@ } if (!empty($rec)) { - $rec['dn'] = $dn; // Add in the dn for the entry. + $rec = self::normalize_entry($rec, true); + if ($dn) { + $rec['dn'] = $dn; // Add in the dn for the entry. + } } } @@ -1121,7 +1148,6 @@ // fetch user attributes if requested if (!empty($attributes)) { $attributes = $this->get_entry($entry_dn, $attributes); - $attributes = self::normalize_entry($attributes, true); } return $entry_dn; @@ -1599,14 +1625,17 @@ } $this->_debug("D: total numsubordinates = " . $vlv_count); } - // ...or by fetching all records dn and count them - else if (!function_exists('ldap_parse_virtuallist_control')) { + // ...or by parsing the controls in the response, and if that's not supported + // by fetching all records dn and counting them + else if (PHP_VERSION_ID < 70305 && !function_exists('ldap_parse_virtuallist_control')) { // @FIXME: this search will ignore $props['search'] $vlv_count = $this->search($base_dn, $filter, $scope, array('dn'), $props, true); } - $this->vlv_active = $this->_vlv_set_controls($sort, $this->list_page, $this->page_size, + $controls = $this->_vlv_set_controls($sort, $this->list_page, $this->page_size, $this->_vlv_search($sort, $props['search'])); + + $this->vlv_active = (bool) $controls; } else { $this->vlv_active = false; @@ -1642,18 +1671,32 @@ $this->_debug("Executing search with return attributes: " . var_export($attrs, true)); - $ldap_result = @$function($this->conn, $base_dn, $filter, $attrs, 0, $sizelimit, $timelimit); + if (is_array($controls)) { + $ldap_result = $function($this->conn, $base_dn, $filter, $attrs, 0, $sizelimit, $timelimit, LDAP_DEREF_NEVER, $controls); + } + else { + $ldap_result = @$function($this->conn, $base_dn, $filter, $attrs, 0, $sizelimit, $timelimit); + } if (!$ldap_result) { $this->_warning("LDAP: $function failed for dn=$base_dn. " . ldap_error($this->conn)); return false; } - // when running on a patched PHP we can use the extended functions - // to retrieve the total count from the LDAP search result - if ($this->vlv_active && function_exists('ldap_parse_virtuallist_control')) { + // when running on a PHP with server controls support we can + // retrieve the total count from the LDAP search result + if ($this->vlv_active && (is_array($controls) || function_exists('ldap_parse_virtuallist_control'))) { if (ldap_parse_result($this->conn, $ldap_result, $errcode, $matcheddn, $errmsg, $referrals, $serverctrls)) { - ldap_parse_virtuallist_control($this->conn, $serverctrls, $last_offset, $vlv_count, $vresult); + if (PHP_VERSION_ID >= 70300) { + $vlv_count = (int) $serverctrls[self::CONTROL_VLV_RESPONSE]['value']['count']; + // FIXME: I don't know this is the same offset value as in ldap_parse_virtuallist_control() below + // but anyway it looks like we do not use that value for anything + $last_offset = (int) $serverctrls[self::CONTROL_VLV_RESPONSE]['value']['target']; + } + else { + ldap_parse_virtuallist_control($this->conn, $serverctrls, $last_offset, $vlv_count, $vresult); + } + $this->_debug("S: VLV result: last_offset=$last_offset; content_count=$vlv_count"); } else { @@ -2068,39 +2111,44 @@ return $this->_vlv_indexes_and_searches; } - $this->_debug("No VLV information available yet, refreshing"); - $search_filter = '(objectclass=vlvsearch)'; + $index_filter = '(objectclass=vlvindex)'; + + $this->_debug("C: Search base dn: [$config_root_dn] scope [sub] with filter [$search_filter]"); + $search_result = ldap_search($this->conn, $config_root_dn, $search_filter, array('*'), 0, 0, 0); if ($search_result === false) { - $this->_debug("Search for '$search_filter' on '$config_root_dn' failed:".ldap_error($this->conn)); - return; + $this->_debug("S: " . ldap_error($this->conn)); + return array(); } + $this->_debug("S: " . ldap_count_entries($this->conn, $search_result) . " record(s) found"); + $vlv_searches = new Net_LDAP3_Result($this->conn, $config_root_dn, $search_filter, 'sub', $search_result); if ($vlv_searches->count() < 1) { - $this->_debug("Empty result from search for '(objectclass=vlvsearch)' on '$config_root_dn'"); - return; + return array(); } - $index_filter = '(objectclass=vlvindex)'; - foreach ($vlv_searches->entries(true) as $vlv_search_dn => $vlv_search_attrs) { // The attributes we are interested in are as follows: $_vlv_base_dn = self::unified_dn($vlv_search_attrs['vlvbase']); $_vlv_scope = $vlv_search_attrs['vlvscope']; $_vlv_filter = $vlv_search_attrs['vlvfilter']; + $this->_debug("C: Search base dn: [$vlv_search_dn] scope [sub] with filter [$index_filter]"); + // Multiple indexes may exist $index_result = ldap_search($this->conn, $vlv_search_dn, $index_filter, array('*'), 0, 0, 0); if ($index_result === false) { - $this->_debug("Search for '$index_filter' on '$vlv_search_dn' failed:".ldap_error($this->conn)); + $this->_debug("S: " . ldap_error($this->conn)); continue; } + $this->_debug("S: " . ldap_count_entries($this->conn, $index_result) . " record(s) found"); + $vlv_indexes = new Net_LDAP3_Result($this->conn, $vlv_search_dn, $index_filter, 'sub', $index_result); $vlv_indexes = $vlv_indexes->entries(true); @@ -2112,12 +2160,12 @@ } $this->_vlv_indexes_and_searches[] = array( - $_vlv_base_dn => array( - 'scope' => self::scopeint2str($_vlv_scope), - 'filter' => strtolower($_vlv_filter), - 'sort' => $_vlv_sort, - ), - ); + $_vlv_base_dn => array( + 'scope' => self::scopeint2str($_vlv_scope), + 'filter' => strtolower($_vlv_filter), + 'sort' => $_vlv_sort, + ), + ); } // cache this @@ -2184,7 +2232,7 @@ return $_schema; } - private function list_group_member($dn, $members, $recurse = true) + protected function list_group_member($dn, $members, $recurse = true) { $this->_debug("Net_LDAP3::list_group_member($dn)"); @@ -2217,7 +2265,7 @@ return array_filter($group_members); } - private function list_group_uniquemember($dn, $uniquemembers, $recurse = true) + protected function list_group_uniquemember($dn, $uniquemembers, $recurse = true) { $this->_debug("Net_LDAP3::list_group_uniquemember($dn)", $entry); @@ -2248,7 +2296,7 @@ return array_filter($group_members); } - private function list_group_memberurl($dn, $memberurls, $recurse = true) + protected function list_group_memberurl($dn, $memberurls, $recurse = true) { $this->_debug("Net_LDAP3::list_group_memberurl($dn)"); @@ -2291,13 +2339,13 @@ * * @return array URL elements */ - private function parse_memberurl($url) + protected function parse_memberurl($url) { preg_match('/(.*):\/\/(.*)\/(.*)\?(.*)\?(.*)\?(.*)/', $url, $matches); return $matches; } - private function modify_entry_attributes($subject_dn, $attributes) + protected function modify_entry_attributes($subject_dn, $attributes) { if (is_array($attributes['rename']) && !empty($attributes['rename'])) { $olddn = $attributes['rename']['dn']; @@ -2392,7 +2440,7 @@ return true; } - private function parse_aclrights(&$attributes, $attribute_value) + protected function parse_aclrights(&$attributes, $attribute_value) { $components = explode(':', $attribute_value); $_acl_target = array_shift($components); @@ -2432,7 +2480,7 @@ } } - private function parse_attribute_level_rights($attribute_value) + protected function parse_attribute_level_rights($attribute_value) { $attribute_value = str_replace(", ", ",", $attribute_value); $attribute_values = explode(",", $attribute_value); @@ -2457,7 +2505,7 @@ return $attribute_value; } - private function parse_entry_level_rights($attribute_value) + protected function parse_entry_level_rights($attribute_value) { $_attribute_value = array(); @@ -2472,53 +2520,38 @@ return $_attribute_value; } - private function supported_controls() + protected function supported_controls() { - if (!empty($this->supported_controls)) { - return $this->supported_controls; - } + $metadata = $this->server_metadata(); - $this->_info("Obtaining supported controls"); - - if ($result = $this->search('', '(objectclass=*)', 'base', array('supportedcontrol'))) { - $result = $result->entries(true); - $control = $result['']['supportedcontrol']; - } - else { - $control = array(); - } + return (array) $metadata['supportedcontrol']; + } - $this->_info("Obtained " . count($control) . " supported controls"); - $this->supported_controls = $control; + protected function vendor_name() + { + $metadata = $this->server_metadata(); - return $control; + return (string) $metadata['vendorname']; } - private function vendor_name() + protected function server_metadata() { - if (!empty($this->vendor_name)) { - return $this->vendor_name; - } + if ($this->_metadata === null) { + $this->_debug("Obtaining LDAP server metadata"); - $this->_info("Obtaining LDAP server vendor name"); + $result = $this->get_entry('', array('vendorname', 'supportedcontrol')); - if ($result = $this->search('', '(objectclass=*)', 'base', array('vendorname'))) { - $result = $result->entries(true); - $name = $result['']['vendorname']; - } - else { - $name = false; - } - - if ($name !== false) { - $this->_info("Vendor name is $name"); - } else { - $this->_info("No vendor name!"); + if ($result) { + $this->_metadata = $result; + $this->_debug("LDAP Server metadata: " . var_export($result, true)); + } + else { + $this->_metadata = array(); + $this->_warning("LDAP: Failed to get server metadata"); + } } - $this->vendor = $name; - - return $name; + return $this->_metadata; } protected function _alert() @@ -2583,39 +2616,6 @@ } /** - * Add BER sequence with correct length and the given identifier - */ - private static function _ber_addseq($str, $identifier) - { - $len = dechex(strlen($str)/2); - if (strlen($len) % 2 != 0) { - $len = '0'.$len; - } - - return $identifier . $len . $str; - } - - /** - * Returns BER encoded integer value in hex format - */ - private static function _ber_encode_int($offset) - { - $val = dechex($offset); - $prefix = ''; - - // check if bit 8 of high byte is 1 - if (preg_match('/^[89abcdef]/', $val)) { - $prefix = '00'; - } - - if (strlen($val)%2 != 0) { - $prefix .= '0'; - } - - return $prefix . $val; - } - - /** * Quotes attribute value string * * @param string $str Attribute value @@ -2689,6 +2689,107 @@ return implode(',', $result); } + private function _fuzzy_search_prefix() + { + switch ($this->config_get("fuzzy_search", 2)) { + case 2: + return "*"; + break; + case 1: + case 0: + default: + return ""; + break; + } + } + + private function _fuzzy_search_suffix() + { + switch ($this->config_get("fuzzy_search", 2)) { + case 2: + return "*"; + break; + case 1: + return "*"; + case 0: + default: + return ""; + break; + } + } + + /** + * Return the search string value to be used in VLV controls + * + * @param array $sort List of attributes in vlv index + * @param array|string $search Search string or attribute => value hash + * + * @return string Search string + */ + private function _vlv_search($sort, $search) + { + if (!empty($this->additional_filter)) { + $this->_debug("Not setting a VLV search filter because we already have a filter"); + return; + } + + if (empty($search)) { + return; + } + + foreach ((array) $search as $attr => $value) { + if ($attr && !in_array(strtolower($attr), $sort)) { + $this->_debug("Cannot use VLV search using attribute not indexed: $attr (not in " . var_export($sort, true) . ")"); + return; + } + else { + return $value . $this->_fuzzy_search_suffix(); + } + } + } + + /** + * Set server controls for Virtual List View (paginated listing) + */ + private function _vlv_set_controls($sort, $list_page, $page_size, $search = null) + { + $sort_ctrl = array( + 'oid' => self::CONTROL_SORT_REQUEST, + 'value' => self::_sort_ber_encode($sort) + ); + + if (!empty($search)) { + $this->_debug("_vlv_set_controls to include search: " . var_export($search, true)); + } + + $vlv_ctrl = array( + 'oid' => self::CONTROL_VLV_REQUEST, + 'value' => self::_vlv_ber_encode( + $offset = ($list_page-1) * $page_size + 1, + $page_size, + $search + ), + 'iscritical' => true + ); + + $this->_debug("C: set controls sort=" . join(' ', unpack('H'.(strlen($sort_ctrl['value'])*2), $sort_ctrl['value'])) + . " (" . implode(',', (array) $sort) . ");" + . " vlv=" . join(' ', (unpack('H'.(strlen($vlv_ctrl['value'])*2), $vlv_ctrl['value']))) . " ($offset/$page_size)"); + + $controls = array($sort_ctrl, $vlv_ctrl); + + if (PHP_VERSION_ID >= 70305) { + return $controls; + } + + if (!ldap_set_option($this->conn, LDAP_OPT_SERVER_CONTROLS, $controls)) { + $this->_debug("S: ".ldap_error($this->conn)); + return false; + } + + return true; + } + /** * create ber encoding for sort control * @@ -2714,18 +2815,6 @@ } /** - * Returns ascii string encoded in hex - */ - private static function _string2hex($str) - { - $hex = ''; - for ($i=0; $i < strlen($str); $i++) - $hex .= dechex(ord($str[$i])); - - return $hex; - } - - /** * Generate BER encoded string for Virtual List View option * * @param integer List offset (first record) @@ -2787,101 +2876,45 @@ return pack('H'.strlen($str), $str); } - private function _fuzzy_search_prefix() + /** + * Add BER sequence with correct length and the given identifier + */ + private static function _ber_addseq($str, $identifier) { - switch ($this->config_get("fuzzy_search", 2)) { - case 2: - return "*"; - break; - case 1: - case 0: - default: - return ""; - break; + $len = dechex(strlen($str)/2); + if (strlen($len) % 2 != 0) { + $len = '0'.$len; } - } - private function _fuzzy_search_suffix() - { - switch ($this->config_get("fuzzy_search", 2)) { - case 2: - return "*"; - break; - case 1: - return "*"; - case 0: - default: - return ""; - break; - } + return $identifier . $len . $str; } /** - * Return the search string value to be used in VLV controls - * - * @param array $sort List of attributes in vlv index - * @param array|string $search Search string or attribute => value hash - * - * @return string Search string + * Returns BER encoded integer value in hex format */ - private function _vlv_search($sort, $search) + private static function _ber_encode_int($offset) { - if (!empty($this->additional_filter)) { - $this->_debug("Not setting a VLV search filter because we already have a filter"); - return; - } + $val = dechex($offset); + $prefix = ''; - if (empty($search)) { - return; + // check if bit 8 of high byte is 1 + if (preg_match('/^[89abcdef]/', $val)) { + $prefix = '00'; } - foreach ((array) $search as $attr => $value) { - if ($attr && !in_array(strtolower($attr), $sort)) { - $this->_debug("Cannot use VLV search using attribute not indexed: $attr (not in " . var_export($sort, true) . ")"); - return; - } - else { - return $value . $this->_fuzzy_search_suffix(); - } + if (strlen($val)%2 != 0) { + $prefix .= '0'; } + + return $prefix . $val; } /** - * Set server controls for Virtual List View (paginated listing) + * Returns ascii string encoded in hex */ - private function _vlv_set_controls($sort, $list_page, $page_size, $search = null) + private static function _string2hex($str) { - $sort_ctrl = array( - 'oid' => "1.2.840.113556.1.4.473", - 'value' => self::_sort_ber_encode($sort) - ); - - if (!empty($search)) { - $this->_debug("_vlv_set_controls to include search: " . var_export($search, true)); - } - - $vlv_ctrl = array( - 'oid' => "2.16.840.1.113730.3.4.9", - 'value' => self::_vlv_ber_encode( - $offset = ($list_page-1) * $page_size + 1, - $page_size, - $search - ), - 'iscritical' => true - ); - - $this->_debug("C: set controls sort=" . join(' ', unpack('H'.(strlen($sort_ctrl['value'])*2), $sort_ctrl['value'])) - . " (" . implode(',', (array) $sort) . ");" - . " vlv=" . join(' ', (unpack('H'.(strlen($vlv_ctrl['value'])*2), $vlv_ctrl['value']))) . " ($offset/$page_size)"); - - if (!ldap_set_option($this->conn, LDAP_OPT_SERVER_CONTROLS, array($sort_ctrl, $vlv_ctrl))) { - $this->_debug("S: ".ldap_error($this->conn)); - $this->set_error(self::ERROR_SEARCH, 'vlvnotsupported'); - - return false; - } - - return true; + return implode(unpack("H*", $str)); } /** @@ -2973,8 +3006,9 @@ public function set_cache_data($key, $data, $ttl = 3600) { if ($cache = $this->get_cache()) { - if (!method_exists($cache, 'replace') || !$cache->replace($key, $data, MEMCACHE_COMPRESSED, $ttl)) { - return $cache->set($key, $data, MEMCACHE_COMPRESSED, $ttl); + $flags = defined('MEMCACHE_COMPRESSED') ? MEMCACHE_COMPRESSED : 0; + if (!method_exists($cache, 'replace') || !$cache->replace($key, $data, $flags, $ttl)) { + return $cache->set($key, $data, $flags, $ttl); } else { return true;
View file
pear-Net-LDAP3-1.0.7.tar.gz/lib/Net/LDAP3/Result.php -> pear-Net-LDAP3-1.1.0.tar.gz/lib/Net/LDAP3/Result.php
Changed
@@ -42,6 +42,7 @@ protected $base_dn; protected $filter; protected $scope; + protected $result; private $count; private $current;
View file
php-net-ldap3.dsc
Changed
@@ -2,7 +2,7 @@ Source: php-net-ldap3 Binary: php-net-ldap3 Architecture: all -Version: 1.0.7-1~kolab1 +Version: 1.1.0-1~kolab1 Maintainer: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> Uploaders: Christoph Wickert <wickert@kolabsys.com> Homepage: http://kolab.org @@ -12,5 +12,5 @@ Package-List: php-net-ldap3 deb php optional Files: - 00000000000000000000000000000000 0 pear-Net-LDAP3-1.0.7.tar.gz + 00000000000000000000000000000000 0 pear-Net-LDAP3-1.1.0.tar.gz 00000000000000000000000000000000 0 debian.tar.gz
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.