@@ -216,7 +216,7 @@ protected function connect($method,$debug=false,$new=false) {
216216 debug_log ('LDAP Resource [%s], Host [%s], Port [%s] ' ,16 ,0 ,__FILE__ ,__LINE__ ,__METHOD__ ,
217217 $ resource ,$ this ->getValue ('server ' ,'host ' ),$ this ->getValue ('server ' ,'port ' ));
218218
219- if (! is_resource ( $ resource) )
219+ if (!$ resource )
220220 debug_dump_backtrace ('UNHANDLED, $resource is not a resource ' ,1 );
221221
222222 # Go with LDAP version 3 if possible (needed for renaming and Novell schema fetching)
@@ -337,7 +337,7 @@ public function login($user=null,$pass=null,$method=null,$new=false) {
337337 $ connect = $ this ->connect ($ method ,false ,$ new );
338338
339339 # If we didnt log in...
340- if (! is_resource ( $ connect) || $ this ->noconnect || ! $ this ->userIsAllowedLogin ($ userDN )) {
340+ if (!$ connect || $ this ->noconnect || ! $ this ->userIsAllowedLogin ($ userDN )) {
341341 $ this ->logout ($ method );
342342
343343 return false ;
@@ -410,22 +410,24 @@ public function query($query,$method,$index=null,$debug=false) {
410410 if ($ debug )
411411 debug_dump (array ('query ' =>$ query ,'server ' =>$ this ->getIndex (),'con ' =>$ this ->connect ($ method )));
412412
413+ $ search = null ;
413414 $ resource = $ this ->connect ($ method ,$ debug );
414415
415- switch ($ query ['scope ' ]) {
416- case 'base ' :
417- $ search = @ldap_read ($ resource ,$ query ['base ' ],$ query ['filter ' ],$ query ['attrs ' ],$ attrs_only ,$ query ['size_limit ' ],$ query ['time_limit ' ],$ query ['deref ' ]);
418- break ;
416+ if ($ resource )
417+ switch ($ query ['scope ' ]) {
418+ case 'base ' :
419+ $ search = @ldap_read ($ resource ,$ query ['base ' ],$ query ['filter ' ],$ query ['attrs ' ],$ attrs_only ,$ query ['size_limit ' ],$ query ['time_limit ' ],$ query ['deref ' ]);
420+ break ;
419421
420- case 'one ' :
421- $ search = @ldap_list ($ resource ,$ query ['base ' ],$ query ['filter ' ],$ query ['attrs ' ],$ attrs_only ,$ query ['size_limit ' ],$ query ['time_limit ' ],$ query ['deref ' ]);
422- break ;
422+ case 'one ' :
423+ $ search = @ldap_list ($ resource ,$ query ['base ' ],$ query ['filter ' ],$ query ['attrs ' ],$ attrs_only ,$ query ['size_limit ' ],$ query ['time_limit ' ],$ query ['deref ' ]);
424+ break ;
423425
424- case 'sub ' :
425- default :
426- $ search = @ldap_search ($ resource ,$ query ['base ' ],$ query ['filter ' ],$ query ['attrs ' ],$ attrs_only ,$ query ['size_limit ' ],$ query ['time_limit ' ],$ query ['deref ' ]);
427- break ;
428- }
426+ case 'sub ' :
427+ default :
428+ $ search = @ldap_search ($ resource ,$ query ['base ' ],$ query ['filter ' ],$ query ['attrs ' ],$ attrs_only ,$ query ['size_limit ' ],$ query ['time_limit ' ],$ query ['deref ' ]);
429+ break ;
430+ }
429431
430432 if ($ debug )
431433 debug_dump (array ('method ' =>$ method ,'search ' =>$ search ,'error ' =>$ this ->getErrorMessage ()));
@@ -1288,7 +1290,7 @@ private function getSchemaDN($method=null,$dn='') {
12881290 $ search = @ldap_read ($ this ->connect ($ method ),$ dn ,'objectclass=* ' ,array ('subschemaSubentry ' ),false ,0 ,10 ,LDAP_DEREF_NEVER );
12891291
12901292 if (DEBUG_ENABLED )
1291- debug_log ('Search returned (%s) ' ,24 ,0 ,__FILE__ ,__LINE__ ,__METHOD__ ,is_resource ( $ search) );
1293+ debug_log ('Search returned (%s) ' ,24 ,0 ,__FILE__ ,__LINE__ ,__METHOD__ ,!! $ search );
12921294
12931295 # Fix for broken ldap.conf configuration.
12941296 if (! $ search && ! $ dn ) {
@@ -1301,7 +1303,7 @@ private function getSchemaDN($method=null,$dn='') {
13011303
13021304 if (DEBUG_ENABLED )
13031305 debug_log ('Search returned (%s) for base (%s) ' ,24 ,0 ,__FILE__ ,__LINE__ ,__METHOD__ ,
1304- is_resource ( $ search) ,$ base );
1306+ !! $ search ,$ base );
13051307
13061308 if ($ search )
13071309 break ;
0 commit comments