summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-01-24 08:18:41 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2013-01-24 08:18:41 (GMT)
commit0529136248f08eaabecdb6aa316285f65814bcdf (patch)
tree98bc3821695f2f989f0ad7523248b308b4e8e901
parent986cdd096a52a97bdac434451a2838ae64af93fa (diff)
downloadNet_LDAP3-0529136248f08eaabecdb6aa316285f65814bcdf.tar.gz
Add some documentation, define dependency to PEAR:Net_LDAP2 package
-rw-r--r--composer.json9
-rw-r--r--lib/Net/LDAP3.php48
2 files changed, 46 insertions, 11 deletions
diff --git a/composer.json b/composer.json
index d76e1c4..1afa0a4 100644
--- a/composer.json
+++ b/composer.json
@@ -23,8 +23,15 @@
"role": "Developer"
}
],
+ "repositories": [
+ {
+ "type": "pear",
+ "url": "http://pear.php.net/"
+ }
+ ],
"require": {
- "php": ">=5.3.3"
+ "php": ">=5.3.3",
+ "pear-pear/Net_LDAP2": ">=2.0.12"
},
"autoload": {
"classmap": ["lib/"]
diff --git a/lib/Net/LDAP3.php b/lib/Net/LDAP3.php
index e34a8af..753d887 100644
--- a/lib/Net/LDAP3.php
+++ b/lib/Net/LDAP3.php
@@ -79,6 +79,8 @@ class Net_LDAP3
'root_dn_db_name' => 'example_org',
'root_dn_db_name_attr' => 'cn',
'config_root_dn' => 'cn=config',
+ 'referrals' => false,
+ 'network_timeout' => 10,
'sizelimit' => 0,
'timelimit' => 0,
// Force VLV off.
@@ -488,6 +490,14 @@ class Net_LDAP3
$this->_current_host = $host;
$this->conn = $lc;
+ if (!empty($this->prop['network_timeout'])) {
+ ldap_set_option(
+ $lc,
+ LDAP_OPT_NETWORK_TIMEOUT,
+ $this->prop['network_timeout']
+ );
+ }
+
if ($this->config_get('referrals', false)) {
ldap_set_option(
$lc,
@@ -1225,6 +1235,17 @@ class Net_LDAP3
return false;
}
+ /**
+ * Execute LDAP search
+ *
+ * @param string $base_dn Base DN to use for searching
+ * @param string $filter Filter string to query
+ * @param string $scope Scope to use for searching: sub, base, one, list
+ * @param array $sort List of attributes to sort results (if VLV is active, this list has to match the VLV index)
+ * @param string $search Search string used in $filter. This is only used if VLV is active
+ *
+ * @return mixed Net_LDAP3_Result instance containing the result set or False on failure
+ */
public function search($base_dn, $filter = '(objectclass=*)', $scope = 'sub', $sort = null, $search = array())
{
if (!$this->conn) {
@@ -1297,14 +1318,15 @@ class Net_LDAP3
return $this->result;
}
+ /**
+ * Similar to Net_LDAP3::search() but using a search array with multiple
+ * keys and values that to continue to use the VLV but with an original
+ * filter adding the search stuff to an additional filter.
+ *
+ * @see Net_LDAP3::search()
+ */
public function search_entries($base_dn, $filter = '(objectclass=*)', $scope = 'sub', $sort = null, $search = array())
{
- /*
- Use a search array with multiple keys and values that to continue
- to use the VLV but with an original filter adding the search stuff
- to an additional filter.
- */
-
$this->_debug("Net_LDAP3::search_entries with search " . var_export($search, true));
if (is_array($search) && array_key_exists('params', $search)) {
@@ -1435,6 +1457,9 @@ class Net_LDAP3
return $rec;
}
+ /**
+ * Normalize a ldap result by converting entry attribute arrays into single values
+ */
public static function normalize_result($__result)
{
if (!is_array($__result)) {
@@ -1619,9 +1644,9 @@ class Net_LDAP3
}
/**
- Return VLV indexes and searches including necessary configuration
- details.
- */
+ * Return VLV indexes and searches including necessary configuration
+ * details.
+ */
private function find_vlv_indexes_and_searches($refresh = false)
{
if (!empty($this->config['vlv'])) {
@@ -1713,7 +1738,10 @@ class Net_LDAP3
private function init_schema()
{
- require_once("Net/LDAP2.php");
+ // use PEAR include if autoloading failed
+ if (!class_exists('Net_LDAP2')) {
+ require_once('Net/LDAP2.php');
+ }
$port = $this->config_get('port', 389);