RELEASE 0.9.8.4

This commit is contained in:
Deon George
2009-06-30 20:28:19 +10:00
parent a01f7c8289
commit c131e8b479
34 changed files with 208 additions and 178 deletions

View File

@@ -1,5 +1,5 @@
<?php
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/server_functions.php,v 1.34.2.29 2006/05/07 05:25:56 wurley Exp $ */
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/server_functions.php,v 1.34.2.32 2007/03/18 01:57:18 wurley Exp $ */
/**
* Classes and functions for LDAP server configuration and capability
@@ -148,7 +148,7 @@ class LDAPserver {
# Quick return if we have already connected.
$resource = $this->_connect($connect_id);
if ($resource && ! $reconnect)
if (is_resource($resource) && ! $reconnect)
return $resource;
if (DEBUG_ENABLED)
@@ -219,7 +219,7 @@ class LDAPserver {
# Now that we have worked out the connect_id, lets just check and see if we have already connected.
$resource = $this->_connect($connect_id);
if ($resource && ! $reconnect)
if (is_resource($resource) && ! $reconnect)
return $resource;
run_hook('pre_connect',array('server_id'=>$this->server_id,'connect_id'=>$connect_id));
@@ -335,7 +335,8 @@ class LDAPserver {
debug_log('%s::getBaseDN(): Connect to LDAP to find BaseDN',80,get_class($this));
if ($this->connect()) {
$r = array_pop($this->search(null,'','objectClass=*',array('namingContexts'),'base'));
$r = $this->search(null,'','objectClass=*',array('namingContexts'),'base');
$r = array_pop($r);
if (is_array($r))
$r = array_change_key_case($r);
@@ -1670,13 +1671,13 @@ class LDAPserver {
* @param array $attrs An array of attributes to include in the search result (example: array( "objectClass", "uid", "sn" )).
* @param string $scope The LDAP search scope. Must be one of "base", "one", or "sub". Standard LDAP search scope.
* @param bool $sort_results Specify false to not sort results by DN or true to have the
* returned array sorted by DN (uses ksort)
* returned array sorted by DN (uses ksort)
* @param int $deref When handling aliases or referrals, this specifies whether to follow referrals. Must be one of
* LDAP_DEREF_ALWAYS, LDAP_DEREF_NEVER, LDAP_DEREF_SEARCHING, or LDAP_DEREF_FINDING. See the PHP LDAP API for details.
* LDAP_DEREF_ALWAYS, LDAP_DEREF_NEVER, LDAP_DEREF_SEARCHING, or LDAP_DEREF_FINDING. See the PHP LDAP API for details.
* @param int $size_limit Size limit for search
* @todo: Add entries to tree cache.
*/
function search($resource=null,$base_dn=null,$filter,$attrs=array(),$scope='sub',$sort_results=true,$deref=LDAP_DEREF_NEVER,$size_limit=0) {
function search($resource=null,$base_dn=null,$filter,$attrs=array(),$scope='sub',$sort_results=false,$deref=LDAP_DEREF_NEVER,$size_limit=0) {
if (DEBUG_ENABLED)
debug_log('%s::search(): Entered with (%s,%s,%s,%s,%s,%s,%s)',17,
get_class($this),is_resource($this),$base_dn,$filter,$attrs,$scope,$sort_results,$deref);
@@ -1719,6 +1720,10 @@ class LDAPserver {
$return = array();
if ($sort_results && is_array($return))
if (version_compare(phpversion(),'4.2.0','>='))
ldap_sort($resource, $search,$sort_results);
# Get the first entry identifier
if ($entry_id = ldap_first_entry($resource,$search))
@@ -1758,8 +1763,6 @@ class LDAPserver {
} # End while entry_id
if ($sort_results && is_array($return))
ksort($return);
if (DEBUG_ENABLED)
debug_log('%s::search(): Returning (%s)',17,get_class($this),$return);
@@ -2440,7 +2443,8 @@ class LDAPserver {
debug_log('%s:getDNAttrs(): Entered with (%s,%s,%s)',17,
get_class($this),$dn,$lower_case_attr_names,$deref);
$attrs = array_pop($this->search(null,dn_escape($dn),'(objectClass=*)',array(),'base',false,$deref));
$attrs = $this->search(null,dn_escape($dn),'(objectClass=*)',array(),'base',false,$deref);
$attrs = array_pop($attrs);
if (is_array($attrs)) {
if ($lower_case_attr_names)