We have a group: "MyTest" in
OU=Domain_users,DС=my,DС=test
We try to find users in this group, trying:
(&(|(sAMAccountName=*$str*)(givenName=*$str*)(sn=*$str*)(middlename=*$str*))(memberOf=CN=MyTest))
and:
(memberOf=CN=MyTest,OU=Domain_users,DС=my,DС=test)
But it doesn't work. When we use filter by user name it works.
In your filter,
will ensure that no results are returned. The attribute
memberOfis a DN which is always the complete valueIf you are unable to find anything using the complete DN above, then just print the complete filter (to console or log) to make sure that you have a valid LDAP filter.
EDIT
Come to think of it, you cannot search on containment on all attributes in LDAP. Especially not
sAMAccountNameAFAIK.Try this first:
And if that works, you may try to search for the attributes using a duplicate OR:
Note the location of the wildcard.
EDIT 2
I took a cup of coffee and read your question again. In Active Directory, group membership is maintained on the group only, not on the user. So you cannot search on
memberOfbut you have to execute 2 calls: one to find the user and one to check the group membership using(member=<user dn>).