Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to LDAP error codes in exceptions #42

Open
althaus opened this issue Mar 22, 2018 · 3 comments
Open

Access to LDAP error codes in exceptions #42

althaus opened this issue Mar 22, 2018 · 3 comments

Comments

@althaus
Copy link
Contributor

althaus commented Mar 22, 2018

Hi,

I'm currently working on an LDAP authentication against a damn huge (200k+ accounts) AD and have some issues with several queries. One thing is a user search which throws the LdapConnectionException in the QueryOperationHandler. Sadly it doesn't contain any helpful message:

'LDAP search failed. Diagnostic message: ""'

It'd be great if the exception could expose the error code or do I miss something?

Cheers
Matthias

@ChadSikorra
Copy link
Contributor

Yes, that seems like a good idea. Not sure why I didn't add that initially. The spot that it needs to be added is here:

https://github.com/ldaptools/ldaptools/blob/18ec773284cdbf5f22cadeb1d85bcaf46c05df39/src/LdapTools/Operation/Handler/OperationHandler.php#L41-L44

Now that I look, there doesn't seem like a good way to get the normal LDAP error code in LdapTools. I can try to add something soon. As a workaround you could do:

ldap_errorno($ldap->getConnection()->getResource());

Sorry about that :-/

@ChadSikorra
Copy link
Contributor

I'm now exposing the last error code in the LdapConnectionException when possible: ldaptools/ldaptools@1943348. However, since I had to change the interface I can't really tag a minor version. If I don't make any other changes soon I'll just tag another release.

However, what operation is triggering your exception? It seems odd that there is no diagnostic message.

@althaus
Copy link
Contributor Author

althaus commented Mar 26, 2018

I've already worked around it by fetching the error codes from the LdapConnection. :)

The issue is all from the same query: A simple loadUserByUsername() on the first login of a new user. The query then died after 120s without details on looking up the user groups. Setting the recursive flag in the config brought the query down to 1s and succeeding.

I'm totally new to LDAP/AD. It's an enterprise scale world wide AD server net with 5 base DNs and 4 levels of OUs each to get down to the users:

OU=USERS,OU="CITY",OU="COUNTRY",OU="FOO",DC=SUB,DC=EXAMPLEWAN,DC=COM

No clue if this is bad by design. It was just a little suprise for me as the contract only told about AD connection for a single location. ;-)

btw: Many thanks for your quick support! 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants