How do I get the BaseDn the user is authenticated against in Zend Framework 2

38 views Asked by At

I have authenticated the user against one of many LDAP configs and I now want to retrieve what the BaseDn is that they have authenticated against so that I can search and get more information for that user.

Debugging at this line:

        if ($auth->hasIdentity()) {

            $uid = $auth->getIdentity();

In debug I can see that the $auth object contains an adapter (Zend\Authentication\Adapter\Ldap) -> ldap (Zend\Ldap\Ldap) -> options[16] and I want BaseDn.

So how/can I get at it from the $auth that's returned?

Apologies if really simple.

1

There are 1 answers

0
Fewster On BEST ANSWER

Apologies, this was very straightforward, will leave this here in case anyone else needs it:

$baseDn = $auth->getAdapter()->getLdap()->getBaseDn();