** ? name => Name for LDAP server (default "LDAP: hostname")
** Used to tag the result data
** ? maxrows => Maximum # of rows in search result
+ ** ? timeout => Timeout for LDAP operations (in seconds, default: 30)
+ ** Might not work for all LDAP libraries or servers.
**
** NOTE. This class should not be used directly. Use the
** "AddressBook" class instead.
var $linkid = false; // PHP LDAP link ID
var $bound = false; // True if LDAP server is bound
var $maxrows = 250; // Max rows in result
-
+ var $timeout = 30; // Timeout for LDAP operations (in seconds)
// Constructor. Connects to database
function abook_ldap_server($param) {
$this->charset = strtolower($param["charset"]);
if(isset($param["maxrows"]))
$this->maxrows = $param["maxrows"];
+ if(isset($param["timeout"]))
+ $this->timeout = $param["timeout"];
if(empty($param["name"]))
$this->sname = "LDAP: ".$param["host"];
else
if(!$this->open())
return false;
- // Do the search
- $sret = @ldap_search($this->linkid, $this->basedn, $expression,
- array("dn", "o", "ou", "sn", "givenname",
- "cn", "mail", "telephonenumber"));
+ // Do the search. Use improved ldap_search() if PHP version is
+ // 4.0.2 or newer.
+ if(sqCheckPHPVersion(4, 0, 2)) {
+ $sret = @ldap_search($this->linkid, $this->basedn, $expression,
+ array("dn", "o", "ou", "sn", "givenname",
+ "cn", "mail", "telephonenumber"),
+ 0, $this->maxrows, $this->timeout);
+ } else {
+ $sret = @ldap_search($this->linkid, $this->basedn, $expression,
+ array("dn", "o", "ou", "sn", "givenname",
+ "cn", "mail", "telephonenumber"));
+ }
// Should get error from server using the ldap_error() function,
// but it only exist in the PHP LDAP documentation.