Skip to content

Add fallback to SIMPLE bind when NTLM fails (e.g. userWorkstations restriction) #80

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

Merged
merged 2 commits into from
Jul 17, 2025

Conversation

Dramelac
Copy link
Member

Original PR on fortra/impacket: fortra#1971

While working in an Active Directory environment, I encountered an issue where Impacket tools like rbcd.py failed to perform an LDAP bind, even though the credentials were valid.

The tool was returning:

1

After investigation, I found that the failure was caused by the userWorkstations LDAP attribute being set for the user. This attribute restricts which machines the user can log on from. Since NTLM authentication includes the client's hostname, the Domain Controller applied this restriction and rejected the bind.

Example of a user with userWorkstations: dc02 set:

2

As a workaround, I modified the _init_ldap_connection() function to:

  • Attempt a NTLM bind first.
  • If it fails, print the LDAP error code (e.g. data 531) and fallback to a SIMPLE bind.

This allowed the bind to succeed, as shown here:

3

Summary of changes:

  • Added a fallback to ldap3.SIMPLE if NTLM fails
  • Added debug output for NTLM bind failures (LDAP error code + human-readable explanation)

⚠️ Note: SIMPLE bind sends credentials in plain text unless LDAPS is used. Use with caution and only when appropriate. This change has also been applied to other LDAP-based tools in Impacket, including dacledit.py and owneredit.py, to improve reliability in similar environments.

@ShutdownRepo ShutdownRepo merged commit b6a3a36 into ThePorgs:main Jul 17, 2025
8 checks passed
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

Successfully merging this pull request may close these issues.

3 participants