Ldap Within Yii Vs Outside It

Hi Everyone,

A quick query I hope you can help with.

External to the yii framework I can successfully bind to, search and add to an external ldap via:




$ds=ldap_connect($ldapoptions['host'],$ldapoptions['port']);

if ($ds) 

{

	echo 'LDAP CONNECTED';

	ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);

    	ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);

	ldap_set_option($ds, LDAP_OPT_DEBUG_LEVEL, 7);

        $r=ldap_bind($ds,$ldapoptions['binddn'],$ldapoptions['bindpass']);

        ...

}



within the yii framework, exactly the same code results in a:

ldap_bind(): Unable to bind to server: Can’t contact LDAP server

Is there any reason this would be the case?

Thanks!

Shouldn’t be. I’ve successfully wrapped an LDAP library in Yii and it works just fine.

What library did you use, and what modifications had to be done?

I have been using the ldaprecord extension, but poor documentation and somewhat buggy code has made me search for alternatives

I was needing to do AD authentication using LDAP, so ended up using this library: http://adldap.sourceforge.net

One thing I ran into with it was that it doesn’t handle recursive queries (which my tool needed to support) through user groups. So I had to subclass it and extend it in a variety of ways. It got messy fast.

But the short version was that I got LDAP queries running against AD with IIS/PHP/MSSQL, so you should be able LDAP queries working if your stack is less weird and twisted :slight_smile:

And you are running the code on the same server, right?