Improvements to debug_log
This commit is contained in:
290
lib/ds_ldap.php
290
lib/ds_ldap.php
@@ -25,6 +25,9 @@ class ldap extends DS {
|
||||
private $force_may = array();
|
||||
|
||||
public function __construct($index) {
|
||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$this->index = $index;
|
||||
$this->type = 'ldap';
|
||||
|
||||
@@ -129,8 +132,8 @@ class ldap extends DS {
|
||||
* @return resource|null Connection resource if successful, null if not.
|
||||
*/
|
||||
protected function connect($method,$debug=false,$new=false) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$method);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
static $CACHE = array();
|
||||
|
||||
@@ -162,7 +165,7 @@ class ldap extends DS {
|
||||
|
||||
# No identifiable connection exists, lets create a new one.
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Creating NEW connection [%s] for index [%s]',16,__FILE__,__LINE__,__METHOD__,
|
||||
debug_log('Creating NEW connection [%s] for index [%s]',16,0,__FILE__,__LINE__,__METHOD__,
|
||||
$method,$this->index);
|
||||
|
||||
if (function_exists('run_hook'))
|
||||
@@ -176,7 +179,7 @@ class ldap extends DS {
|
||||
$CACHE[$this->index][$method] = $resource;
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('LDAP Resource [%s], Host [%s], Port [%s]',16,__FILE__,__LINE__,__METHOD__,
|
||||
debug_log('LDAP Resource [%s], Host [%s], Port [%s]',16,0,__FILE__,__LINE__,__METHOD__,
|
||||
$resource,$this->getValue('server','host'),$this->getValue('server','port'));
|
||||
|
||||
if (! is_resource($resource))
|
||||
@@ -206,11 +209,11 @@ class ldap extends DS {
|
||||
debug_dump(array('method'=>$method,'bind'=>$bind,'USER'=>$_SESSION['USER']));
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Resource [%s], Bind Result [%s]',16,__FILE__,__LINE__,__METHOD__,$resource,$bind);
|
||||
debug_log('Resource [%s], Bind Result [%s]',16,0,__FILE__,__LINE__,__METHOD__,$resource,$bind);
|
||||
|
||||
if (! $bind['result']) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Leaving with FALSE, bind FAILed',16,__FILE__,__LINE__,__METHOD__);
|
||||
debug_log('Leaving with FALSE, bind FAILed',16,0,__FILE__,__LINE__,__METHOD__);
|
||||
|
||||
$this->noconnect = true;
|
||||
|
||||
@@ -248,6 +251,9 @@ class ldap extends DS {
|
||||
* @todo isLoginStringEnabled() based logins
|
||||
*/
|
||||
public function login($user=null,$pass=null,$method=null,$new=false) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$userDN = null;
|
||||
|
||||
# Get the userDN from the username.
|
||||
@@ -306,6 +312,9 @@ class ldap extends DS {
|
||||
* @return array|null Results of query.
|
||||
*/
|
||||
public function query($query,$method,$index=null,$debug=false) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$size_limit = 500;
|
||||
$time_limit = 0;
|
||||
$attrs_only = 0;
|
||||
@@ -347,11 +356,7 @@ class ldap extends DS {
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__,
|
||||
$query,$index,$debug);
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('%s search PREPARE.',16,__FILE__,__LINE__,__METHOD__,$query['scope']);
|
||||
debug_log('%s search PREPARE.',16,0,__FILE__,__LINE__,__METHOD__,$query['scope']);
|
||||
|
||||
if ($debug)
|
||||
debug_dump(array('query'=>$query,'server'=>$this->getIndex(),'con'=>$this->connect($method)));
|
||||
@@ -377,7 +382,7 @@ class ldap extends DS {
|
||||
debug_dump(array('method'=>$method,'search'=>$search,'error'=>$this->getErrorMessage()));
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Search scope [%s] base [%s] filter [%s] attrs [%s] COMPLETE (%s).',16,__FILE__,__LINE__,__METHOD__,
|
||||
debug_log('Search scope [%s] base [%s] filter [%s] attrs [%s] COMPLETE (%s).',16,0,__FILE__,__LINE__,__METHOD__,
|
||||
$query['scope'],$query['base'],$query['filter'],$query['attrs'],is_null($search));
|
||||
|
||||
if (! $search)
|
||||
@@ -429,7 +434,7 @@ class ldap extends DS {
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning (%s)',17,__FILE__,__LINE__,__METHOD__,$return);
|
||||
debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$return);
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -440,6 +445,9 @@ class ldap extends DS {
|
||||
* @param string Which connection method resource to use
|
||||
*/
|
||||
public function getErrorMessage($method=null) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
return ldap_error($this->connect($method));
|
||||
}
|
||||
|
||||
@@ -449,6 +457,9 @@ class ldap extends DS {
|
||||
* @param string Which connection method resource to use
|
||||
*/
|
||||
public function getErrorNum($method=null) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
return ldap_errno($this->connect($method));
|
||||
}
|
||||
|
||||
@@ -461,6 +472,9 @@ class ldap extends DS {
|
||||
* @param string Which connection method resource to use
|
||||
*/
|
||||
public function getLoginID($user,$method=null) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$query['filter'] = sprintf('(&(uid=%s))',$user);
|
||||
$query['attrs'] = array('dn');
|
||||
$result = $this->query($query,$method);
|
||||
@@ -479,6 +493,9 @@ class ldap extends DS {
|
||||
* Return if anonymous bind is allowed in the configuration
|
||||
*/
|
||||
public function isAnonBindAllowed() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
return $this->getValue('login','anon_bind');
|
||||
}
|
||||
|
||||
@@ -493,6 +510,9 @@ class ldap extends DS {
|
||||
* @return boolean
|
||||
*/
|
||||
private function isTLSEnabled() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if ($this->getValue('server','tls') && ! function_exists('ldap_start_tls')) {
|
||||
error(_('TLS has been enabled in your config, but your PHP install does not support TLS. TLS will be disabled.'),'warn');
|
||||
return false;
|
||||
@@ -505,6 +525,9 @@ class ldap extends DS {
|
||||
* If TLS is configured, then start it
|
||||
*/
|
||||
private function startTLS($resource) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if (! $this->getValue('server','tls') || (function_exists('ldap_start_tls') && ! ldap_start_tls($resource)))
|
||||
error(_('Could not start TLS. Please check your LDAP server configuration.'),'error',null,true);
|
||||
}
|
||||
@@ -520,6 +543,9 @@ class ldap extends DS {
|
||||
* @return boolean
|
||||
*/
|
||||
private function isSASLEnabled() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if ($this->getValue('server','sasl') && ! function_exists('ldap_sasl_bind')) {
|
||||
error(_('SASL has been enabled in your config, but your PHP install does not support SASL. SASL will be disabled.'),'warn');
|
||||
return false;
|
||||
@@ -535,6 +561,9 @@ class ldap extends DS {
|
||||
* @todo This has not been tested, please let the developers know if this function works as expected.
|
||||
*/
|
||||
private function startSASL($resource,$method) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
error(__METHOD__.' has NOT been tested, please let us know if it works and which version of PHP you are using.','info');
|
||||
static $CACHE = array();
|
||||
|
||||
@@ -551,7 +580,7 @@ class ldap extends DS {
|
||||
if (! trim($this->getValue('sasl','authz_id'))) {
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Rewriting bind DN [%s] -> authz_id with regex [%s] and replacement [%s].',9,__FILE__,__LINE__,__METHOD__,
|
||||
debug_log('Rewriting bind DN [%s] -> authz_id with regex [%s] and replacement [%s].',9,0,__FILE__,__LINE__,__METHOD__,
|
||||
$CACHE['login_dn'],
|
||||
$this->getValue('sasl','authz_id_regex'),
|
||||
$this->getValue('sasl','authz_id_replacement'));
|
||||
@@ -566,7 +595,7 @@ class ldap extends DS {
|
||||
'error','index.php');
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Resource [%s], SASL OPTIONS: mech [%s], realm [%s], authz_id [%s], props [%s]',9,__FILE__,__LINE__,__METHOD__,
|
||||
debug_log('Resource [%s], SASL OPTIONS: mech [%s], realm [%s], authz_id [%s], props [%s]',9,0,__FILE__,__LINE__,__METHOD__,
|
||||
$resource,
|
||||
$this->getValue('sasl','mech'),
|
||||
$this->getValue('sasl','realm'),
|
||||
@@ -595,6 +624,9 @@ class ldap extends DS {
|
||||
* @return boolean
|
||||
*/
|
||||
private function isProxyEnabled() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
return $this->getValue('login','auth_type') == 'proxy' ? true : false;
|
||||
}
|
||||
|
||||
@@ -602,6 +634,9 @@ class ldap extends DS {
|
||||
* If PROXY AUTH is configured, then start it
|
||||
*/
|
||||
private function startProxy($resource,$method) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$rootdse = $this->getRootDSE();
|
||||
|
||||
if (! (isset($rootdse['supportedcontrol']) && in_array('2.16.840.1.113730.3.4.18',$rootdse['supportedcontrol']))) {
|
||||
@@ -688,6 +723,9 @@ class ldap extends DS {
|
||||
* Modify attributes of a DN
|
||||
*/
|
||||
public function modify($dn,$attrs,$method=null) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# We need to supress the error here - programming should detect and report it.
|
||||
return @ldap_mod_replace($this->connect($method),$dn,$attrs);
|
||||
}
|
||||
@@ -708,8 +746,8 @@ class ldap extends DS {
|
||||
* @todo Sort the entries, so that they are in the correct DN order.
|
||||
*/
|
||||
public function getBaseDN($method=null) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$method);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
static $CACHE;
|
||||
|
||||
@@ -722,14 +760,14 @@ class ldap extends DS {
|
||||
# If the base is set in the configuration file, then just return that.
|
||||
if (count($this->getValue('server','base'))) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Return BaseDN from Config [%s]',17,__FILE__,__LINE__,__METHOD__,implode('|',$this->getValue('server','base')));
|
||||
debug_log('Return BaseDN from Config [%s]',17,0,__FILE__,__LINE__,__METHOD__,implode('|',$this->getValue('server','base')));
|
||||
|
||||
$CACHE[$this->index][$method] = $this->getValue('server','base');
|
||||
|
||||
# We need to figure it out.
|
||||
} else {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Connect to LDAP to find BaseDN',80,__FILE__,__LINE__,__METHOD__);
|
||||
debug_log('Connect to LDAP to find BaseDN',80,0,__FILE__,__LINE__,__METHOD__);
|
||||
|
||||
# Set this to empty, in case we loop back here looking for the baseDNs
|
||||
$CACHE[$this->index][$method] = array();
|
||||
@@ -738,7 +776,7 @@ class ldap extends DS {
|
||||
|
||||
if (isset($results['namingcontexts'])) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('LDAP Entries:%s',80,__FILE__,__LINE__,__METHOD__,implode('|',$results['namingcontexts']));
|
||||
debug_log('LDAP Entries:%s',80,0,__FILE__,__LINE__,__METHOD__,implode('|',$results['namingcontexts']));
|
||||
|
||||
$result = $results['namingcontexts'];
|
||||
}
|
||||
@@ -758,8 +796,8 @@ class ldap extends DS {
|
||||
* @return boolean
|
||||
*/
|
||||
public function dnExists($dn,$method=null) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Search for (%s)',16,__FILE__,__LINE__,__METHOD__,$dn);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$results = $this->getDNAttrValues($dn,$method);
|
||||
|
||||
@@ -776,6 +814,9 @@ class ldap extends DS {
|
||||
* @return string The container
|
||||
*/
|
||||
public function getContainerTop($dn) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$return = $dn;
|
||||
|
||||
foreach ($this->getBaseDN() as $base) {
|
||||
@@ -786,7 +827,7 @@ class ldap extends DS {
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s), Returning (%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$return);
|
||||
debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$return);
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -799,8 +840,8 @@ class ldap extends DS {
|
||||
* @return string The container
|
||||
*/
|
||||
public function getContainerPath($dn,$path='..') {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$path);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$top = $this->getContainerTop($dn);
|
||||
|
||||
@@ -846,23 +887,25 @@ class ldap extends DS {
|
||||
* @return string The container
|
||||
*/
|
||||
public function getContainer($dn) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$parts = $this->explodeDN($dn);
|
||||
|
||||
if (count($parts) <= 1)
|
||||
$container = null;
|
||||
$return = null;
|
||||
|
||||
else {
|
||||
$container = $parts[1];
|
||||
$return = $parts[1];
|
||||
|
||||
for ($i=2;$i<count($parts);$i++)
|
||||
$container .= sprintf(',%s',$parts[$i]);
|
||||
$return .= sprintf(',%s',$parts[$i]);
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,
|
||||
$dn,$container);
|
||||
debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$return);
|
||||
|
||||
return $container;
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -899,8 +942,8 @@ class ldap extends DS {
|
||||
* @return array An array of DN strings listing the immediate children of the specified entry.
|
||||
*/
|
||||
public function getContainerContents($dn,$method=null,$size_limit=0,$filter='(objectClass=*)',$deref=LDAP_DEREF_NEVER) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$size_limit,$filter,$deref);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$return = array();
|
||||
|
||||
@@ -921,7 +964,7 @@ class ldap extends DS {
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning (%s)',17,__FILE__,__LINE__,__METHOD__,$return);
|
||||
debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$return);
|
||||
|
||||
# Sort the results
|
||||
asort($return);
|
||||
@@ -949,14 +992,14 @@ class ldap extends DS {
|
||||
* NOTE: When a multivalue RDN is passed to ldap_explode_dn, the results returns with 'value + value';
|
||||
*/
|
||||
private function explodeDN($dn,$with_attributes=0) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$dn,$with_attributes);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
static $CACHE;
|
||||
|
||||
if (isset($CACHE['explode'][$dn][$with_attributes])) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Return CACHED result (%s) for (%s)',1,__FILE__,__LINE__,__METHOD__,
|
||||
debug_log('Return CACHED result (%s) for (%s)',1,0,__FILE__,__LINE__,__METHOD__,
|
||||
$CACHE['explode'][$dn][$with_attributes],$dn);
|
||||
|
||||
return $CACHE['explode'][$dn][$with_attributes];
|
||||
@@ -969,7 +1012,7 @@ class ldap extends DS {
|
||||
$result[1] = ldap_explode_dn($this->escapeDN($dn),1);
|
||||
if (! $result[$with_attributes]) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning NULL - NO result.',1,__FILE__,__LINE__,__METHOD__);
|
||||
debug_log('Returning NULL - NO result.',1,0,__FILE__,__LINE__,__METHOD__);
|
||||
|
||||
return array();
|
||||
}
|
||||
@@ -988,8 +1031,7 @@ class ldap extends DS {
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,
|
||||
$dn,$with_attributes,$result[$with_attributes]);
|
||||
debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$result[$with_attributes]);
|
||||
|
||||
return $result[$with_attributes];
|
||||
}
|
||||
@@ -998,11 +1040,12 @@ class ldap extends DS {
|
||||
* Parse a DN and escape any special characters
|
||||
*/
|
||||
protected function escapeDN($dn) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if (! trim($dn))
|
||||
return $dn;
|
||||
|
||||
$olddn = $dn;
|
||||
|
||||
# Check if the RDN has a comma and escape it.
|
||||
while (preg_match('/([^\\\\]),(\s*[^=]*\s*),/',$dn))
|
||||
$dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*),/','$1\\\\2C$2,',$dn);
|
||||
@@ -1010,8 +1053,7 @@ class ldap extends DS {
|
||||
$dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*)([^,])$/','$1\\\\2C$2$3',$dn);
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,
|
||||
$olddn,$dn);
|
||||
debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$dn);
|
||||
|
||||
return $dn;
|
||||
}
|
||||
@@ -1020,6 +1062,9 @@ class ldap extends DS {
|
||||
* Parse a DN and unescape any special characters
|
||||
*/
|
||||
private function unescapeDN($dn) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if (is_array($dn)) {
|
||||
$a = array();
|
||||
foreach ($dn as $key => $rdn)
|
||||
@@ -1032,6 +1077,9 @@ class ldap extends DS {
|
||||
}
|
||||
|
||||
public function getRootDSE($method=null) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$query = array();
|
||||
$query['base'] = '';
|
||||
$query['scope'] = 'base';
|
||||
@@ -1057,8 +1105,8 @@ class ldap extends DS {
|
||||
* @return array|false Schema if available, null if its not or false if we cant connect.
|
||||
*/
|
||||
private function getSchemaDN($method=null,$dn='') {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',25,__FILE__,__LINE__,__METHOD__,$dn);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# If we already got the SchemaDN, then return it.
|
||||
if ($this->_schemaDN)
|
||||
@@ -1070,19 +1118,19 @@ class ldap extends DS {
|
||||
$search = @ldap_read($this->connect($method),$dn,'objectClass=*',array('subschemaSubentry'));
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Search returned (%s)',24,__FILE__,__LINE__,__METHOD__,is_resource($search));
|
||||
debug_log('Search returned (%s)',24,0,__FILE__,__LINE__,__METHOD__,is_resource($search));
|
||||
|
||||
# Fix for broken ldap.conf configuration.
|
||||
if (! $search && ! $dn) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Trying to find the DN for "broken" ldap.conf',80,__FILE__,__LINE__,__METHOD__);
|
||||
debug_log('Trying to find the DN for "broken" ldap.conf',80,0,__FILE__,__LINE__,__METHOD__);
|
||||
|
||||
if (isset($this->_baseDN)) {
|
||||
foreach ($this->_baseDN as $base) {
|
||||
$search = @ldap_read($this->connect($method),$base,'objectClass=*',array('subschemaSubentry'));
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Search returned (%s) for base (%s)',24,__FILE__,__LINE__,__METHOD__,
|
||||
debug_log('Search returned (%s) for base (%s)',24,0,__FILE__,__LINE__,__METHOD__,
|
||||
is_resource($search),$base);
|
||||
|
||||
if ($search)
|
||||
@@ -1096,7 +1144,7 @@ class ldap extends DS {
|
||||
|
||||
if (! @ldap_count_entries($this->connect($method),$search)) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Search returned 0 entries. Returning NULL',25,__FILE__,__LINE__,__METHOD__);
|
||||
debug_log('Search returned 0 entries. Returning NULL',25,0,__FILE__,__LINE__,__METHOD__);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -1104,7 +1152,7 @@ class ldap extends DS {
|
||||
$entries = @ldap_get_entries($this->connect($method),$search);
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Search returned [%s]',24,__FILE__,__LINE__,__METHOD__,$entries);
|
||||
debug_log('Search returned [%s]',24,0,__FILE__,__LINE__,__METHOD__,$entries);
|
||||
|
||||
if (! $entries || ! is_array($entries))
|
||||
return null;
|
||||
@@ -1112,7 +1160,7 @@ class ldap extends DS {
|
||||
$entry = isset($entries[0]) ? $entries[0] : false;
|
||||
if (! $entry) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entry is false, Returning NULL',80,__FILE__,__LINE__,__METHOD__);
|
||||
debug_log('Entry is false, Returning NULL',80,0,__FILE__,__LINE__,__METHOD__);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -1120,7 +1168,7 @@ class ldap extends DS {
|
||||
$sub_schema_sub_entry = isset($entry[0]) ? $entry[0] : false;
|
||||
if (! $sub_schema_sub_entry) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Sub Entry is false, Returning NULL',80,__FILE__,__LINE__,__METHOD__);
|
||||
debug_log('Sub Entry is false, Returning NULL',80,0,__FILE__,__LINE__,__METHOD__);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -1128,7 +1176,7 @@ class ldap extends DS {
|
||||
$this->_schemaDN = isset($entry[$sub_schema_sub_entry][0]) ? $entry[$sub_schema_sub_entry][0] : false;
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning (%s)',25,__FILE__,__LINE__,__METHOD__,$this->_schemaDN);
|
||||
debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$this->_schemaDN);
|
||||
|
||||
return $this->_schemaDN;
|
||||
}
|
||||
@@ -1161,8 +1209,8 @@ class ldap extends DS {
|
||||
* etc.
|
||||
*/
|
||||
private function getRawSchema($method,$schema_to_fetch,$dn='') {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s)',25,__FILE__,__LINE__,__METHOD__,$schema_to_fetch,$dn);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$valid_schema_to_fetch = array('objectclasses','attributetypes','ldapsyntaxes','matchingrules','matchingruleuse');
|
||||
|
||||
@@ -1176,7 +1224,7 @@ class ldap extends DS {
|
||||
$schema = $this->_schema_entries[$schema_to_fetch];
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning CACHED (%s)',25,__FILE__,__LINE__,__METHOD__,$schema);
|
||||
debug_log('Returning CACHED (%s)',25,0,__FILE__,__LINE__,__METHOD__,$schema);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
@@ -1198,11 +1246,11 @@ class ldap extends DS {
|
||||
|
||||
if ($schema_dn) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Using Schema DN (%s)',24,__FILE__,__LINE__,__METHOD__,$schema_dn);
|
||||
debug_log('Using Schema DN (%s)',24,0,__FILE__,__LINE__,__METHOD__,$schema_dn);
|
||||
|
||||
foreach (array('(objectClass=*)','(objectClass=subschema)') as $schema_filter) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Looking for schema with Filter (%s)',24,__FILE__,__LINE__,__METHOD__,$schema_filter);
|
||||
debug_log('Looking for schema with Filter (%s)',24,0,__FILE__,__LINE__,__METHOD__,$schema_filter);
|
||||
|
||||
$schema_search = @ldap_read($this->connect($method),$schema_dn,$schema_filter,array($schema_to_fetch),0,0,0,LDAP_DEREF_NEVER);
|
||||
|
||||
@@ -1212,18 +1260,18 @@ class ldap extends DS {
|
||||
$schema_entries = @ldap_get_entries($this->connect($method),$schema_search);
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Search returned [%s]',24,__FILE__,__LINE__,__METHOD__,$schema_entries);
|
||||
debug_log('Search returned [%s]',24,0,__FILE__,__LINE__,__METHOD__,$schema_entries);
|
||||
|
||||
if (is_array($schema_entries) && isset($schema_entries['count']) && $schema_entries['count']) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Found schema with (DN:%s) (FILTER:%s) (ATTR:%s)',24,__FILE__,__LINE__,__METHOD__,
|
||||
debug_log('Found schema with (DN:%s) (FILTER:%s) (ATTR:%s)',24,0,__FILE__,__LINE__,__METHOD__,
|
||||
$schema_dn,$schema_filter,$schema_to_fetch);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Didnt find schema with filter (%s)',24,__FILE__,__LINE__,__METHOD__,$schema_filter);
|
||||
debug_log('Didnt find schema with filter (%s)',24,0,__FILE__,__LINE__,__METHOD__,$schema_filter);
|
||||
|
||||
unset($schema_entries);
|
||||
$schema_search = null;
|
||||
@@ -1234,7 +1282,7 @@ class ldap extends DS {
|
||||
* is still null, use some common subSchemaSubentry DNs as a work-around. */
|
||||
if (is_null($schema_search)) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Attempting work-arounds for "broken" LDAP servers...',24,__FILE__,__LINE__,__METHOD__);
|
||||
debug_log('Attempting work-arounds for "broken" LDAP servers...',24,0,__FILE__,__LINE__,__METHOD__);
|
||||
|
||||
foreach ($this->getBaseDN() as $base) {
|
||||
$ldap['W2K3 AD'][expand_dn_with_base($base,'cn=Aggregate,cn=Schema,cn=configuration,')] = '(objectClass=*)';
|
||||
@@ -1248,7 +1296,7 @@ class ldap extends DS {
|
||||
foreach ($ldap as $ldap_server_name => $ldap_options) {
|
||||
foreach ($ldap_options as $ldap_dn => $ldap_filter) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Attempting [%s] (%s) (%s)<BR>',24,__FILE__,__LINE__,__METHOD__,
|
||||
debug_log('Attempting [%s] (%s) (%s)<BR>',24,0,__FILE__,__LINE__,__METHOD__,
|
||||
$ldap_server_name,$ldap_dn,$ldap_filter);
|
||||
|
||||
$schema_search = @ldap_read($this->connect($method),$ldap_dn,$ldap_filter,
|
||||
@@ -1259,17 +1307,17 @@ class ldap extends DS {
|
||||
$schema_entries = @ldap_get_entries($this->connect($method),$schema_search);
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Search returned [%s]',24,__FILE__,__LINE__,__METHOD__,$schema_entries);
|
||||
debug_log('Search returned [%s]',24,0,__FILE__,__LINE__,__METHOD__,$schema_entries);
|
||||
|
||||
if ($schema_entries && isset($schema_entries[0][$schema_to_fetch])) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Found schema with filter of (%s)',24,__FILE__,__LINE__,__METHOD__,$ldap_filter);
|
||||
debug_log('Found schema with filter of (%s)',24,0,__FILE__,__LINE__,__METHOD__,$ldap_filter);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Didnt find schema with filter (%s)',24,__FILE__,__LINE__,__METHOD__,$ldap_filter);
|
||||
debug_log('Didnt find schema with filter (%s)',24,0,__FILE__,__LINE__,__METHOD__,$ldap_filter);
|
||||
|
||||
unset($schema_entries);
|
||||
$schema_search = null;
|
||||
@@ -1285,7 +1333,7 @@ class ldap extends DS {
|
||||
* Attempt to pull schema from Root DSE with scope "one" (work-around for Isode M-Vault X.500/LDAP) */
|
||||
foreach (array('base','one') as $ldap_scope) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Attempting to find schema with scope (%s), filter (objectClass=*) and a blank base.',24,__FILE__,__LINE__,__METHOD__,
|
||||
debug_log('Attempting to find schema with scope (%s), filter (objectClass=*) and a blank base.',24,0,__FILE__,__LINE__,__METHOD__,
|
||||
$ldap_scope);
|
||||
|
||||
switch ($ldap_scope) {
|
||||
@@ -1303,17 +1351,17 @@ class ldap extends DS {
|
||||
|
||||
$schema_entries = @ldap_get_entries($this->connect($method),$schema_search);
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Search returned [%s]',24,__FILE__,__LINE__,__METHOD__,$schema_entries);
|
||||
debug_log('Search returned [%s]',24,0,__FILE__,__LINE__,__METHOD__,$schema_entries);
|
||||
|
||||
if ($schema_entries && isset($schema_entries[0][$schema_to_fetch])) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Found schema with filter of (%s)',24,__FILE__,__LINE__,__METHOD__,'(objectClass=*)');
|
||||
debug_log('Found schema with filter of (%s)',24,0,__FILE__,__LINE__,__METHOD__,'(objectClass=*)');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Didnt find schema with filter (%s)',24,__FILE__,__LINE__,__METHOD__,'(objectClass=*)');
|
||||
debug_log('Didnt find schema with filter (%s)',24,0,__FILE__,__LINE__,__METHOD__,'(objectClass=*)');
|
||||
|
||||
unset($schema_entries);
|
||||
$schema_search = null;
|
||||
@@ -1333,7 +1381,7 @@ class ldap extends DS {
|
||||
'type'=>'error'));
|
||||
else
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning because schema_search is NULL ()',25,__FILE__,__LINE__,__METHOD__);
|
||||
debug_log('Returning because schema_search is NULL ()',25,0,__FILE__,__LINE__,__METHOD__);
|
||||
|
||||
# We'll set this, so if we return here our cache will return the known false.
|
||||
$this->_schema_entries[$schema_to_fetch] = false;
|
||||
@@ -1343,7 +1391,7 @@ class ldap extends DS {
|
||||
if (! $schema_entries) {
|
||||
$return = false;
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning false since ldap_get_entries() returned false.',25,__FILE__,__LINE__,__METHOD__,$return);
|
||||
debug_log('Returning false since ldap_get_entries() returned false.',25,0,__FILE__,__LINE__,__METHOD__,$return);
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1357,7 +1405,7 @@ class ldap extends DS {
|
||||
$return = false;
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning because (%s) isnt in the schema array. (%s)',25,__FILE__,__LINE__,__METHOD__,$schema_to_fetch,$return);
|
||||
debug_log('Returning because (%s) isnt in the schema array. (%s)',25,0,__FILE__,__LINE__,__METHOD__,$schema_to_fetch,$return);
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1374,7 +1422,7 @@ class ldap extends DS {
|
||||
$this->_schema_entries[$schema_to_fetch] = $schema;
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning (%s)',25,__FILE__,__LINE__,__METHOD__,$schema);
|
||||
debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$schema);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
@@ -1392,6 +1440,9 @@ class ldap extends DS {
|
||||
* @see SchemaObjectClasses
|
||||
*/
|
||||
public function getSchemaObjectClass($oclass_name,$method=null,$dn='') {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$oclass_name = strtolower($oclass_name);
|
||||
$socs = $this->SchemaObjectClasses($method,$dn);
|
||||
|
||||
@@ -1402,8 +1453,7 @@ class ldap extends DS {
|
||||
$return = $socs[$oclass_name];
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s), Returning (%s).',25,__FILE__,__LINE__,__METHOD__,
|
||||
$oclass_name,$dn,$return);
|
||||
debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$return);
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1421,6 +1471,9 @@ class ldap extends DS {
|
||||
* @see SchemaAttributes
|
||||
*/
|
||||
public function getSchemaAttribute($attr_name,$method=null,$dn='') {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$attr_name = strtolower($attr_name);
|
||||
$sattrs = $this->SchemaAttributes($method,$dn);
|
||||
|
||||
@@ -1431,8 +1484,7 @@ class ldap extends DS {
|
||||
$return = $sattrs[$attr_name];
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s), Returning (%s).',25,__FILE__,__LINE__,__METHOD__,
|
||||
$attr_name,$dn,$return);
|
||||
debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$return);
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1451,15 +1503,15 @@ class ldap extends DS {
|
||||
* @see getSchemaObjectClass
|
||||
*/
|
||||
public function SchemaObjectClasses($method=null,$dn='') {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',25,__FILE__,__LINE__,__METHOD__,$dn);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# Set default return
|
||||
$return = null;
|
||||
|
||||
if ($return = get_cached_item($this->index,'schema','objectclasses')) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning CACHED [%s] (%s)',25,__FILE__,__LINE__,__METHOD__,$this->index,'objectclasses');
|
||||
debug_log('Returning CACHED [%s] (%s)',25,0,__FILE__,__LINE__,__METHOD__,$this->index,'objectclasses');
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1491,7 +1543,7 @@ class ldap extends DS {
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning (%s)',25,__FILE__,__LINE__,__METHOD__,$return);
|
||||
debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$return);
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1507,15 +1559,15 @@ class ldap extends DS {
|
||||
* @return array An array of AttributeType objects.
|
||||
*/
|
||||
public function SchemaAttributes($method=null,$dn='') {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',25,__FILE__,__LINE__,__METHOD__,$dn);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# Set default return
|
||||
$return = null;
|
||||
|
||||
if ($return = get_cached_item($this->index,'schema','attributes')) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('(): Returning CACHED [%s] (%s)',25,__FILE__,__LINE__,__METHOD__,$this->index,'attributes');
|
||||
debug_log('(): Returning CACHED [%s] (%s)',25,0,__FILE__,__LINE__,__METHOD__,$this->index,'attributes');
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1676,7 +1728,7 @@ class ldap extends DS {
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning (%s)',25,__FILE__,__LINE__,__METHOD__,$return);
|
||||
debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$return);
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1686,12 +1738,15 @@ class ldap extends DS {
|
||||
* The key of each entry is the OID of the matching rule.
|
||||
*/
|
||||
public function MatchingRules($method=null,$dn='') {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# Set default return
|
||||
$return = null;
|
||||
|
||||
if ($return = get_cached_item($this->index,'schema','matchingrules')) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning CACHED [%s] (%s).',25,__FILE__,__LINE__,__METHOD__,$this->index,'matchingrules');
|
||||
debug_log('Returning CACHED [%s] (%s).',25,0,__FILE__,__LINE__,__METHOD__,$this->index,'matchingrules');
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1749,7 +1804,7 @@ class ldap extends DS {
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s), Returning (%s).',25,__FILE__,__LINE__,__METHOD__,$dn,$return);
|
||||
debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$return);
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1759,12 +1814,15 @@ class ldap extends DS {
|
||||
* their descriptions. The key of each entry is the OID of the Syntax.
|
||||
*/
|
||||
public function SchemaSyntaxes($method=null,$dn='') {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# Set default return
|
||||
$return = null;
|
||||
|
||||
if ($return = get_cached_item($this->index,'schema','syntaxes')) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning CACHED [%s] (%s).',25,__FILE__,__LINE__,__METHOD__,$this->index,'syntaxes');
|
||||
debug_log('Returning CACHED [%s] (%s).',25,0,__FILE__,__LINE__,__METHOD__,$this->index,'syntaxes');
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1795,7 +1853,7 @@ class ldap extends DS {
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s), Returning (%s).',25,__FILE__,__LINE__,__METHOD__,$dn,$return);
|
||||
debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$return);
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1808,8 +1866,8 @@ class ldap extends DS {
|
||||
* otherwise.
|
||||
*/
|
||||
function isForceMay($attr_name) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
return in_array($attr_name,$this->force_may);
|
||||
}
|
||||
@@ -1843,9 +1901,8 @@ class ldap extends DS {
|
||||
* @todo Caching these values may be problematic with multiple calls and different deref values.
|
||||
*/
|
||||
public function getDNAttrValue($dn,$attr,$method=null,$deref=LDAP_DEREF_NEVER) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__,
|
||||
$dn,$attr,$method,$deref);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# Ensure our attr is in lowercase
|
||||
$attr = strtolower($attr);
|
||||
@@ -1898,8 +1955,8 @@ class ldap extends DS {
|
||||
* @see getDNAttrValue
|
||||
*/
|
||||
public function getDNAttrValues($dn,$method=null,$deref=LDAP_DEREF_NEVER,$attrs=array('*','+')) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$method,$deref,$attrs);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
static $CACHE;
|
||||
|
||||
@@ -1914,12 +1971,11 @@ class ldap extends DS {
|
||||
$cacheindex = '*';
|
||||
|
||||
if (! is_null($cacheindex) && isset($CACHE[$this->index][$method][$dn][$cacheindex])) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s,%s,%s), Returning CACHED (%s)',17,__FILE__,__LINE__,__METHOD__,
|
||||
$dn,$method,$deref,$attrs,$CACHE[$this->index][$method][$dn][$cacheindex]);
|
||||
|
||||
$results = $CACHE[$this->index][$method][$dn][$cacheindex];
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$results);
|
||||
|
||||
} else {
|
||||
$query = array();
|
||||
$query['base'] = $this->escapeDN($dn);
|
||||
@@ -1957,8 +2013,8 @@ class ldap extends DS {
|
||||
* @return boolean
|
||||
*/
|
||||
function isDNAttr($attr_name,$method=null) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# Simple test first
|
||||
$dn_attrs = array('aliasedObjectName');
|
||||
@@ -1998,8 +2054,8 @@ class ldap extends DS {
|
||||
* @see draw_jpeg_photo
|
||||
*/
|
||||
function isJpegPhoto($attr_name) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# easy quick check
|
||||
if (! strcasecmp($attr_name,'jpegPhoto') || ! strcasecmp($attr_name,'photo'))
|
||||
@@ -2029,8 +2085,8 @@ class ldap extends DS {
|
||||
* @return boolean
|
||||
*/
|
||||
function isAttrBoolean($attr_name) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$type = ($sattr = $this->getSchemaAttribute($attr_name)) ? $sattr->getType() : null;
|
||||
|
||||
@@ -2055,8 +2111,8 @@ class ldap extends DS {
|
||||
* @see isJpegPhoto
|
||||
*/
|
||||
function isAttrBinary($attr_name) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
/**
|
||||
* Determining if an attribute is binary can be an expensive operation.
|
||||
@@ -2139,8 +2195,8 @@ class ldap extends DS {
|
||||
* @return bool true|false
|
||||
*/
|
||||
function userIsMember($user,$group) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s)',17,__FILE__,__LINE__,__METHOD__,$user,$group);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$user = strtolower($user);
|
||||
$group = $this->getDNAttrValues($group);
|
||||
@@ -2170,8 +2226,8 @@ class ldap extends DS {
|
||||
* This function will determine if the user is allowed to login based on a filter
|
||||
*/
|
||||
protected function userIsAllowedLogin($dn) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$dn);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$dn = trim(strtolower($dn));
|
||||
|
||||
@@ -2180,7 +2236,7 @@ class ldap extends DS {
|
||||
|
||||
foreach ($this->getValue('login','allowed_dns') as $login_allowed_dn) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Working through (%s)',80,__FILE__,__LINE__,__METHOD__,$login_allowed_dn);
|
||||
debug_log('Working through (%s)',80,0,__FILE__,__LINE__,__METHOD__,$login_allowed_dn);
|
||||
|
||||
/* Check if $login_allowed_dn is an ldap search filter
|
||||
* Is first occurence of 'filter=' (case ensitive) at position 0 ? */
|
||||
@@ -2195,7 +2251,7 @@ class ldap extends DS {
|
||||
$results = $this->query($query,null);
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Search, Filter [%s], BaseDN [%s] Results [%s]',16,__FILE__,__LINE__,__METHOD__,
|
||||
debug_log('Search, Filter [%s], BaseDN [%s] Results [%s]',16,0,__FILE__,__LINE__,__METHOD__,
|
||||
$query['filter'],$query['base'],$results);
|
||||
|
||||
if ($results) {
|
||||
@@ -2209,7 +2265,7 @@ class ldap extends DS {
|
||||
if (count($dn_array))
|
||||
foreach ($dn_array as $result_dn) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Comparing with [%s]',80,__FILE__,__LINE__,__METHOD__,$result_dn);
|
||||
debug_log('Comparing with [%s]',80,0,__FILE__,__LINE__,__METHOD__,$result_dn);
|
||||
|
||||
# Check if $result_dn is a user DN
|
||||
if (strcasecmp($dn,trim(strtolower($result_dn))) == 0)
|
||||
|
Reference in New Issue
Block a user