Re: ldap_search...no results!

From: Date: Tue, 17 Apr 2001 03:40:57 +0000
Subject: Re: ldap_search...no results!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-48883@lists.php.net to get a copy of this message
Previously, Miguel Carvalho said: > if a do > ldapsearch -o ",o=xyz" "ent=entry1,uid=ldap,ou=People,o=xyz", it > works just fine. > > How can i access the entry "ent=entry1,uid=ldap,ou=People,o=xyz" using > ldap_search/ldap_list or ldap_read? > > I have tried ldap_search... but i can not find how to write the filter. $host = 'localhost'; $bindcred = 'uid=admin'; // adjust for your system $bindpass = 'somepasswd'; // adjust for your system $base = 'o=xyz'; // where to start in tree //$base = 'uid=ldap,ou=People,o=xyz'; // more specific... and // probably faster too $filter = 'ent=entry1'; // what to search on $conn = ldap_connect($host); if (! $conn) die('LDAP connection failed!'); $result = ldap_bind($conn, $bindcred, $bindpass); if (! $result) die('LDAP BIND failed!'); $result = ldap_search($conn, $base, $filter); if (! $result) die('LDAP SRCH failed!'); $numentries = ldap_count_entries($conn, $result); print 'Found ' . $numentries . 'matches<br>'; if ($numentries > 0) $info = ldap_get_entries($conn, $result); for ($i = 0; $i < $info['count']; $i++) { print $info[$i]['uid'][0]; } // $info is a multidimensional array with your result set. // you can use another attribute name in place of 'uid'... // for multivalued attributes (such as 'objectclass') you can use // numbers higher than 0 in the last set of brackets to see the // other values... i.e. // // $info[$i]['objectclass'][0]; // $info[$i]['objectclass'][1]; // $info[$i]['objectclass'][2]; // // .. etc -- Why don't sheep shrink when it rains? -George Carlin

« previous php.general (#48883) next »