goauthentik / goauthentik/authentik
LDAP Password change queries wrong active directory domain in same forest
- Dominant language
- Python
- Stars
- 25.6k
- Forks
- 2k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 644
Description
**Describe the bug**
-
LDAP Password change not possible via Authentik. When trying to change the password, Authentik tries to contact domain controllers from a different domain. Everything else works fine.
Only the **password reset** seems to use the wrong connection attributes from ldap3 module and **contacts the AD forest instead of the AD domain**. Firewall logs and tcpdump show Authentik contacting 6 available domain controllers - in the wrong domain.
I used python and ldap3 myself to reprocude the steps Authentik takes and arrived at the same point.
Might want to use **different attributes from ldap3.connection.server.info**, like **"dnsHostName"**, or the **host part of "ldapServiceName"** in **line 66** here: https://github.com/goauthentik/authentik/blob/main/authentik/sources/ldap/password.py
[Here's Microsofts description](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/7ee04fa8-8027-4c7e-9c4a-4cd4c0198a70) of the attribute "rootDomainNamingContext" that's currently used - that attribute refers to the forest root instead of the user account's domain. Disclaimer: I'm no expert on active directory, just found all that during troublehsooting, so someone else might know better what the right attribute is in that situation ;-)
**To Reproduce**
-
Screenshot should explain it all. As an alternative, do this:
1. Use Multi-Domain Active Directory Forest.
2. Forest name is equal to the name of one of the child domains, say "Domain1".
3. Log on to Authentik as user from another child domain, say "Domain5".
4. Try to reset password, Authentik will query "Domain1".
5. Look at tcpdump or firewall logs to verify.
**Expected behavior**
-
Authentik queries a domain controller from the domain the user belongs to, just as it does when user logons are verified, or users get synced via LDAP.
**Screenshots**
-
I ran my reproduction with python3 and pip-installed ldap3 module, fresh downloads, just an hour ago:

**Logs**
**Version and Deployment (please complete the following information):**
**Additional context**
Contributor guide
Assessment
This issue has not been assessed yet.