Skip to Main Content

Security Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PHP ldap_search against DS 5.2

807573Apr 27 2007 — edited Apr 30 2007
We are switching from NIS to LDAP using Sun One Directory server 5.2.
I have to convert all our web PHP login scripts that are NIS based to LDAP.

I'm having difficult time just trying to do simple ldap_search, always coming up with "No such object in test.php on line 19. Below is the php code:

<?php

$info = array("userPassword","homeDirectory");
$rdn = "cn=proxy,ou=profile,dc=engr,dc=colostate,dc=edu";
$rdnPass = "password";
$basedn = "ou=People,cn=engr,cn=colostate,cn=edu";
$filter = "(uid=joeblow)";

$ds = ldap_connect("ldap.server.ip.here");
if (!$ds) {
print "System Error";
exit(0);
}
$bind = ldap_bind($ds, $rdn, $rdnPass);
if (!$bind) {
print "System bind error";
exit(0);
}
$sr = ldap_search($ds, $basedn, $filter, $info);
if (!$sr) {
print "Ldap_search failed\n";
}
else {
$info = ldap_get_entries($ds, $sr);
print $info["count"]." entries returned\n";
}
ldap_close($ds);
?>

Here are logs for the DS server:

[27/Apr/2007:12:46:06 -0600] conn=108 op=-1 msgId=-1 - fd=38 slot=38 LDAP connection from 129.82.xxx.xx to 129.82.xxx.xxx
[27/Apr/2007:12:46:06 -0600] conn=108 op=0 msgId=1 - BIND dn="cn=proxy,ou=profile,dc=engr,dc=colostate,dc=edu" method=128 version=2
[27/Apr/2007:12:46:06 -0600] conn=108 op=0 msgId=1 - RESULT err=0 tag=97 nentries=0 etime=0 dn="cn=proxy,ou=profile,dc=engr,dc=colostate,dc=edu"
[27/Apr/2007:12:46:06 -0600] conn=108 op=1 msgId=2 - SRCH base="ou=people,cn=engr,cn=colostate,cn=edu" scope=2 filter="(uid=joeblow)" attrs="userPassword homeDirectory"
[27/Apr/2007:12:46:06 -0600] conn=108 op=1 msgId=2 - RESULT err=32 tag=101 nentries=0 etime=0
[27/Apr/2007:12:46:06 -0600] conn=108 op=2 msgId=3 - UNBIND
[27/Apr/2007:12:46:06 -0600] conn=108 op=2 msgId=-1 - closing - U1
[27/Apr/2007:12:46:06 -0600] conn=108 op=-1 msgId=-1 - closed.

I've tried compiling PHP against openLDAP and the native ldap libraries on Solaris 10 in /usr/lib. But get same error regardless. Any ideas what I'm doing wrong in the code?
And yes, uid joeblow does exist in LDAP.

client1 % ldaplist -l passwd joeblow
dn: uid=joeblow,ou=people,dc=engr,dc=colostate,dc=edu
objectClass: posixAccount
objectClass: shadowAccount
objectClass: account
objectClass: top
uid: joeblow
cn: joeblow
uidNumber: 902
gidNumber: 66
gecos: Average User test acct,,,
homeDirectory: /top/students/UNGRAD/ES/joeblow/home
loginShell: /bin/csh


Thanks...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 28 2007
Added on Apr 27 2007
7 comments
423 views