LDAP search filter for Active Directory
Posted
by Francesco De Vittori
on Server Fault
See other posts from Server Fault
or by Francesco De Vittori
Published on 2010-05-20T09:30:42Z
Indexed on
2010/05/20
9:41 UTC
Read the original article
Hit count: 488
ldap
|active-directory
Hello,
I'm trying to look for users inside Active Directory through a LDAP query. Basically I'm searching for the user in this way:
Search DN: dc=mydomain, dc=com
Filter: (sAMAccountName=USER) where USER is replaced with the provided username.
Now if USER is only the username without domain (for ex. "Joe") this works fine. However I receive them in the form (domain\username, for ex. "myDomain\Joe") and obviously the search fails.
I see two ways:
- using a regex inside the Search Filter to discard the domain
- using a completely different search filter
I'm no LDAP expert and I don't even know if it's possible to use regular expressions inside the search filters.
Does anyone know if it's possible and how?
P.S. I cannot pre-process the username to strip the domain. This cannot be changed, as it's all part of a large system.
© Server Fault or respective owner