cvs: pear /DB_ldap ldap.php
| From: | Ludovico Magnocavallo | Date: | Sat, 19 Jan 2002 16:08:10 +0000 |
| Subject: | cvs: pear /DB_ldap ldap.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-2005@lists.php.net to get a copy of this message | ||
ludoo Sat Jan 19 11:08:10 2002 EDT
Modified files:
/pear/DB_ldap ldap.php
Log:
added base() method to DB_ldap to set a search base different from the connection base, patch
contributed by Piotr Roszatyck <Piotr_Roszatycki@netia.net.pl>
Index: pear/DB_ldap/ldap.php
diff -u pear/DB_ldap/ldap.php:1.3 pear/DB_ldap/ldap.php:1.4
--- pear/DB_ldap/ldap.php:1.3 Wed Jan 16 05:38:44 2002
+++ pear/DB_ldap/ldap.php Sat Jan 19 11:08:10 2002
@@ -20,7 +20,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//
-// $Id: ldap.php,v 1.3 2002/01/16 10:38:44 ludoo Exp $
+// $Id: ldap.php,v 1.4 2002/01/19 16:08:10 ludoo Exp $
//
require_once 'DB/common.php';
@@ -107,11 +107,11 @@
// begin third loop, iterate through attribute values
if (!is_int($value_idx)) continue;
if (empty($value)) $value = $attr_value;
-/* else {
+ else {
if (is_array($value)) $value[] = $attr_value;
else $value = array($value, $attr_value);
}
-*/ else $value .= "\n$attr_value";
+// else $value .= "\n$attr_value";
// end third loop
}
$rs[$attr] = $value;
@@ -304,6 +304,11 @@
*/
var $base = '';
/**
+ * query base dn
+ * @access private
+ */
+ var $q_base = '';
+ /**
* array of LDAP actions that only manipulate data
* returning a true/false value
* @access private
@@ -414,7 +419,7 @@
$params = (count($this->q_params) > 0 ? $this->q_params : array());
}
if (!$this->isManip($action)) {
- $base = $this->base;
+ $base = $this->q_base ? $this->q_base : $this->base;
$attributes = array();
$attrsonly = 0;
$sizelimit = 0;
@@ -430,11 +435,11 @@
$this->sorting_method = $sorting_method;
$this->attributes = $attributes;
if ($action == 'search')
- $result = ldap_search($this->connection, $this->base, $filter, $attributes,
$attrsonly, $sizelimit, $timelimit, $deref);
+ $result = ldap_search($this->connection, $base, $filter, $attributes,
$attrsonly, $sizelimit, $timelimit, $deref);
else if ($action == 'list')
- $result = ldap_list($this->connection, $this->base, $filter, $attributes,
$attrsonly, $sizelimit, $timelimit, $deref);
+ $result = ldap_list($this->connection, $base, $filter, $attributes, $attrsonly,
$sizelimit, $timelimit, $deref);
else if ($action == 'read')
- $result = ldap_read($this->connection, $this->base, $filter, $attributes,
$attrsonly, $sizelimit, $timelimit, $deref);
+ $result = ldap_read($this->connection, $base, $filter, $attributes, $attrsonly,
$sizelimit, $timelimit, $deref);
else
return $this->raiseError(DB_ERROR_UNKNOWN_LDAP_ACTION);
if (!$result) {
@@ -740,6 +745,13 @@
$this->sorting = '';
return true;
}
+
+ function base($base = null)
+ {
+ $this->q_base = $base ? $base : null;
+ return true;
+ }
+
}