LDAP auth, "Domain Search Filter" & "complex" filter
I have a problem with the "Domain Search Filter" in the LDAP auth module:
-
If I use a simple filter like: attributeX=Y it works
-
If I use a more complex filter like: (&(attributeX=Y)(attributeZ=W)) it doesnt work
Is there a special way to format this filter or is it not supported ?
We got this filter working by leaving out some parenthesis.
This would be normally the correct form for our LDAP filter:
(&(memberof=CN=Group1,OU=Ounit1,DC=example,DC=com)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
In above, user must be a member of group called Group1 AND the account must NOT be in disabled state in Windows Active Directory. However, this does not work with RC.
By trial and error we got this working instead:
&(memberof=CN=Group1,OU=Ounit1,DC=example,DC=com)!(userAccountControl:1.2.840.113556.1.4.803:=2)
So you might get this working:
&(attributeX=Y)(attributeZ=W)
It works ! thanks ! For the record, you can add multiple conditions (more than two): |(attr=A)(attr=B)(attr=C) which means A or B or C can log in.
This does not appear to be functioning any more. Please try testing on latest builds and you will find that !(userAccountControl:1.2.840.113556.1.4.803:=2) does not function.
@iesit Our current working LDAP filter is:
(|(&(memberof=CN=all_users,OU=exampleou,DC=example,DC=com)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))(|(CN=extraaccount1)(CN=extraaccount2)(CN=extraaccount3)(CN=extraaccount4)(CN=extraaccount5)))
Parenthesis were fixed maybe a year a go, and correct LDAP syntax works with the latest stable version (0.74.3) at least. Disabled accounts are not populated to rocketchat.
(Extra accounts are for those that do not belong to all_users group.)
Thanks! I'll continue testing. Out of curiosity, are you using Microsoft Active Directory? What is your domain functional level?
Thank you!
@iesit Yes, we are using AD, functionality level is on Win 2008 R2. I don't expect problems with higher functionality levels, as to my knowledge AD components and functionality haven't changed much during the years, but we too will find out in the near future as the support for Win2008r2 ends in January 2020 and we have to upgrade.
Hmm... I wonder if my memberOf filter isn't working because of a space in the CN. It seems to still be importing disabled users even when I'm asking it not to... I've worked around it for now by not synchronizing, and just letting users log in individually, so that the directory only contains those employees who have logged in previously.