[Phpwm] PHP and LDAP

Tony Whitmore phpwm at tonywhitmore.co.uk
Sat Sep 9 22:36:56 BST 2006


Marc Gale wrote:
> I write a lot of PHP<->LDAP code and the following method works well for me.
> 
> As with most database connection models, set yourself up a series of
> connection variables:
> 
> $ldapuser="FULL DN OF USER";
> $ldappass="USER'S PASSWORD";
> $ldapserver="NAME OF LDAP SERVER";
> 
> Now try to connect to the LDAP tree:
> 
> $ldapconn=ldap_connect($ldapserver) or die("Could not connect to LDAP");
> 
> If that's worked, try binding as the user
> 
> $ldapbind=ldap_bind($ldapconn,$ldapuser,$ldappass) or die("Couldn't bind to
> the LDAP");
> 
> If you just want an anonymous connection (read only access to certain parts
> of the tree), then you can bind in the following way:
> 
> $ldapbind=ldap_bind($ldapconn) or die("Couldn't bind to the LDAP");
> 
> I hope that helps

Thanks Marc and David. I haven't had time to put this into practice yet,
but it's really helpful advice.

I guess I need to populate my LDAP server with some sample data now, to
save me setting up loads of test users.

Cheers,

Tony



More information about the Phpwm mailing list