Paul Moldovan
Paul Moldovan

Reputation: 464

another way to connect with ZEND auth ldap

I want to connect to a ldap server. I've done it by using the following code in application.ini

ldap.server.host = ldaps://ldap.example.ro
ldap.server.username = "uid=admin,ou=people,dc=example,dc=ro"
ldap.server.password = "password"
ldap.server.baseDn = "ou=people,dc=example,dc=ro"
ldap.server.bindRequiresDn = true

and then

    $auth = Zend_Auth::getInstance();

    $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini',
                                'production');
    $options = $config->ldap->toArray();

    $adapter = new Zend_Auth_Adapter_Ldap($options, $username, $password);

    $result = $auth->authenticate($adapter);

Is there any way that i can do the same thing just without admin and password ? without ldap.server.username and ldap.server.password

Upvotes: 1

Views: 2018

Answers (1)

Paul Moldovan
Paul Moldovan

Reputation: 464

I found a way. So simple...

in application.ini

 ldap.server.host = ldaps://ldap.example.ro
 ldap.server.baseDn = "ou=people,dc=example,dc=ro"

and the only difference is that the $username must be

 $username = "uid=". $username . ",ou=people,dc=example,dc=ro"

Upvotes: 1

Related Questions