Grabbing all UIDs from LDAP database
| From: | H. Wade Minter | Date: | Mon, 02 Oct 2000 22:38:23 +0000 |
| Subject: | Grabbing all UIDs from LDAP database | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-18321@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hey folk,
I'm trying to build a list of currently-used UIDs, but I'm having trouble
connecting, searching, and building an array of this one attribute. The
stuff I'm working with is below, but if anyone has a better solution, I'd
love to hear of it.
"uidnumber" is the numeric UID that I want to collect.
The code below outputs the following errors:
Died getting first entry
Warning: 0 is not a LDAP result entry index in
/usr/local/apache/htdocs/adduser.php on line 47
Died getting values
########
$ldap=ldap_connect($ldap_server) or die ("Could not connect to LDAP
server $server\n");
if (!(ldap_bind($ldap,$dn,"")))
{
die ("Could not bind for UID search\n");
}
$filter = "uidnumber=*";
$attributes=array("uidnumber");
$basedn="dc=netraverse,dc=com";
if (!($result = ldap_read($ldap,$basedn,$filter,$attributes)))
{
print "Died doing ldap_read\n";
}
if (!($entry = ldap_first_entry($ldap, $result)))
{
print "Died getting first entry\n";
}
if (!($values = ldap_get_values($ldap,$entry,"uidnumber")))
{
print "Died getting values\n";
}
ldap_close($ldap);
#######
- --
H. Wade Minter | NeTraverse, Inc.
System Administrator | minter@netraverse.com
"Whatever it is that you're not doing, go don't do it somewhere else."
--Sheriff, "Manos: Hands of Fate"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.2 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE52Q5hX5y4ZKLK2pMRAnJZAJ9aZwfCTJD7o7f/NQ9ICRw/ncmnEwCgwSDn
tZdsJqr5HtsiRd/wDkOsmeM=
=0QSs
-----END PGP SIGNATURE-----