Re: Getting the distinguished name when using Auth with the LDAP container

From: Date: Thu, 04 May 2006 13:19:25 +0000
Subject: Re: Getting the distinguished name when using Auth with the LDAP container
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-23929@lists.php.net to get a copy of this message
> I'm using the PEAR Auth Package and an LDAP directory to authenticate > users. If the user gets authenticated he should be able to perform a few > queries on the LDAP directory. > > I'm working with Net_LDAP to perform these queries and I'd like to use > the distinguished name of the authenticated user to bind against the > LDAP directory. > > How can I get the distinguished name returned to the search by Auth? I > am not getting along with the source of Auth. Where is the retrieved DN > stored and how can I access it (if I'm able to access is)? Hi, as we meet each other again here, I'll try to be clearer this time ;-) 1. Auth binds as a user, with which it can search the ldap tree 2. It looks for the user, by doing a search defined by your paramters (objectclass, subtree, scope etc.) 3. It eventually finds that user and tries to authenticate with his credentials 4. It then returns true or false The dn it binds with in step 3 is NOT saved anywhere, just used inside the function fetchData. My suggestion is, that you can fetch additional data from the found object. This would be the attribute dn. So you pass in your options array 'attributes' => array('dn') and it will fetch this attribute. Could be done with username, surname, objectClass or whatever you want. You can then access this data with $auth->getAuthData('attributes'). This is more a rough example than a howto, but it should work. The only problem could be, that you cannot specify dn as an attribute to be fetched. Didn't try that. ... as my first mail bounced, I took time to check on that and dn is not returned. So one would have to change fetchData, to actually save $user_dn in AuthData if 'dn' is in attributes. What do the other authors say? Cheers Jan -- Jan Wagner <wagner@netsols.de> netsols.de

« previous php.pear.general (#23929) next »