Re: PHP4 & LDAP

From: Date: Wed, 20 Mar 2002 22:19:10 +0000
Subject: Re: PHP4 & LDAP
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-17793@lists.php.net to get a copy of this message
Just in case anyone was wondering, here's a bit more info. I'm not sure why some attributes show up the other way though: <? $baseDN = "dc=mydomain,dc=com"; $bindDN = "uid=dumbuser,dc=mydomain,dc=com"; $bindPass = "mypass"; $linkID = ldap_connect(ldapServer,ldapPort); if ($linkID) if (ldap_bind($linkID,$bindDN,$bindPass) == false) DO SOME ERROR PARSING $filter = "uid=dumbuser"; $search = ldap_search($linkID,$baseDN,$filter); $entry = ldap_first_entry($linkID,$search); #<- ALL TOO IMPORTANT LINE $values = ldap_get_values($linkID,$entry,"departmentNumber"); for ($i = 0; $i < $values["count"]; $i++) print $i . ":" . $values[$i] . <br>\n"; ldap_close($linkID); ?> Now (for some reason I haven't figured out yet) if you don't do the ldap_first_entry() step, you cannot access all of the attribute values returned from the $search! You can test by commenting it out and changing the $values line to use the $search value as the second arg. I hope that helps someone. I could have used it for sure. David Christensen wrote:
Not sure if this is the right list for this, but I didn't see any others on the PHP web site that made sense... I'm using the following packages: php-common-4.1.2-1mdk php-4.1.2-1mdk mod_php-4.1.2-1mdk php-ldap-4.1.2-1mdk openldap-clients-2.0.21-1.1mdk openldap-servers-2.0.21-1.1mdk openldap-2.0.21-1.1mdk libldap2-2.0.21-1.1mdk php-ldap-4.1.2-1mdk apache-modules-1.3.23-4mdk apache-common-1.3.23-4mdk apache-conf-1.3.23-3mdk apache-1.3.23-4mdk I'm trying to use my LDAP server for privilege access to certain portions of the site. I'm verifying the user's account information via LDAP and that seems to work ok, because I can bind and do a modify on the user's information. I'm updating a particular field to hold the sessionID and a time stamp. The record updates just fine, because I can do a "ldapsearch" from the command line on the server using the same credentials I use in PHP and I can see the update. I also have the server WIDE OPEN at the moment to test. I didn't want any stray ACL's to get in the way of debugging this. The problem arises when I try to read back all of the attributes within the PHP script. I can see only certain attributes: uid, mail, cn (the normal stuff) but if I try to read these fields that I want to use for the session, they don't print in PHP, but the show up from the LDAP command line util. The fields include: employeeNumber, carLicense, departmentNumber. Like I said earlier, I can update them from PHP, just can't read them back. Any ideas are greatly appreciated! David Christensen


« previous php.db (#17793) next »