Ldap Filter Broken in 60.3 and 60.4
Description:
The authentication with rocket chat users not works. The LDAP connection works fine, and the authentication of the user seems too. But the result it's always: User not found or incorrect password What is wrong in my configuration?
Server Setup Information:
Version of Rocket.Chat Server: 0.60.3 and 0.60.3
Operating System: centOS7
Deployment Method(snap/docker/tar/etc): docker
Number of Running Instances: 2
DB Replicaset Oplog:
Node Version: n 8.9.3
Steps to Reproduce:
- Updated to 0.60.3 also tested with 0.60.4
- Ldap search filter in the settings is: (&(|(objectclass=inetOrgPerson)(objectclass=sambaSamAccount)(objectclass=shadowAccount))(|(mail=#{username})(uid=#{username})))
- Try to login with ldap
- Error: User not found or incorrect password
- Debug log query is wrong: LDAP ➔ Search.debug searchOptions { filter: '(&(&(|(objectclass=inetOrgPerson)(objectclass=sambaSamAccount)(objectclass=shadowAccount))(|(mail=#{username})(uid=#{username})))(|(uid=jdoe)(mail=jdoe)))',
Expected behavior:
Login works as before the update
Actual behavior:
Error: User not found or incorrect password
Relevant logs:
Debug log query is wrong: LDAP ➔ Search.debug searchOptions { filter: '(&(&(|(objectclass=inetOrgPerson)(objectclass=sambaSamAccount)(objectclass=shadowAccount))(|(mail=#{username})(uid=#{username})))(|(uid=jdoe)(mail=jdoe)))',
I have same problem (but with AD LDAP).
Debug log:
(&(&(objectCategory=person)(objectclass=user)(memberOf=CN=XXX,OU=XXX,DC=contoso,DC=com))(sAMAccountName=username))
This filter worked with version 0.59.6
I have same problem also with AD LDAP.
Debug log:
LDAP -> Search.debug: searchOptions { filter: '(&(&(objectCategory=person)(objectclass=user)(memberOf:1.2.840.113556.1.4.1941:=CN=AG-RocketChat-LoginAccess,OU=RocketChat,OU=AccessGroups,OU=Organizational Accounts,DC=company,DC=local)(|(mail=#{username})(sAMAccountName=#{username})))(sAMAccountName=Scream85))'
Worked in 0.58.3:
LDAP -> Search.debug: searchOptions { filter: '(&(objectCategory=person)(objectclass=user)(memberOf:1.2.840.113556.1.4.1941:=CN=AG-RocketChat-LoginAccess,OU=RocketChat,OU=AccessGroups,OU=Organizational Accounts,DC=company,DC=local)(|(mail=Scream85)(sAMAccountName=Scream85)))'
For the reference our LDAP filter still works:
(|(&(memberof=CN=all_users,OU=groups,DC=example,DC=com)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))(|(CN=account1)(CN=account2)(CN=account3)(CN=account4)))
This brings members of all_users group, excluding disabled ones, plus couple of independent accounts.
As of 0.60.x there is a new configuration value for ldap auth: admin - ldap - user search - search field where you must specify ldap attributes to be used in authentication requests. the replacement of the username with #{username} in ldap filters does not work anymore.
I could not find any descriptions about changing the filters. How to solve a problem?
@bbrauns What shall we use instead of #{username} then?
https://rocket.chat/docs/administrator-guides/authentication/ldap/#ldap
Still shows #{username} as the variable I need to use.
see Gummikavalier comment. i have removed the username variable and it works.
Indeed it works now for me too. Somewhere between 0.58.x and 0.60.x the LDAP authentication part had been redesigned.
Instead of using:
{“filter”: “(&(objectCategory=person)(objectclass=user)(memberOf=CN=ROCKET_ACCESS,CN=Users,DC=domain,DC=com)((mail=#{username})(sAMAccountName=#{username})))”, “scope”: “sub”, “userDN”: “[email protected]”, “password”: “urpass”}
Now under LDAP -> User Search in the Filter field, you'll need to use:
(&(objectCategory=person)(objectclass=user)(memberOf=CN=ROCKET_ACCESS,CN=Users,DC=domain,DC=com))
in the Scope field: sub
in the Search Field field: sAMAccountName
and set the credentials under LDAP -> Authentication.
Two note here:
- Meanwhile the help under the LDAP -> Authentication -> User DN field says, I should use
cn=Administrator,cn=Users,dc=Example,dc=comformat, that didn't work for me. Instead plainly using just the username of the LDAP query service account works well. (v0.61.1) - Meanwhile the help under the LDAP -> User Search -> Search Field field says, I can use multiple identifiers with a comma separator. That didn't work for me, when I set
sAMAccountName,mail. I couldn't log in with my user's email address, although I still could with my username.
I would recommend to update the https://rocket.chat/docs/administrator-guides/authentication/ldap/ site to reflect this changes. Will cause less confusion for those setting up Rocket.Chat for the first time with LDAP authentication.
Anyone still running into this problem? Otherwise I'll close the issue.
im facing still this problem ...
using this filter and still not working ...
(&(objectClass=user)(memberof:1.2.840.113556.1.4.1941:=CN=RocketChat,OU=Applications,OU=Shared,DC=XXX,DC=local))
I'm seeing this with RocketChat 3.0.7. It seems that sometimes the authentication works and sometimes it doesn't.
server.js:204 LDAPHandler ➔ error Error: User not Found
at MethodInvocation.<anonymous> (app/ldap/server/loginHandler.js:60:10)
at packages/accounts-base/accounts_server.js:460:31
at tryLoginMethod (packages/accounts-base/accounts_server.js:1289:14)
at AccountsServer._runLoginHandlers (packages/accounts-base/accounts_server.js:458:22)
at AccountsServer.Accounts._runLoginHandlers (app/lib/server/lib/loginErrorMessageOverride.js:7:35)
at MethodInvocation.methods.login (packages/accounts-base/accounts_server.js:518:31)
at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1771:12)
at packages/ddp-server/livedata_server.js:719:19
at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
at packages/ddp-server/livedata_server.js:717:46
at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
at packages/ddp-server/livedata_server.js:715:46
at new Promise (<anonymous>)
at Session.method (packages/ddp-server/livedata_server.js:689:23)
at packages/ddp-server/livedata_server.js:559:43
3.8.2 has this error. No reports from users with login issues yet....
rocketchat_1 | server.js:204 LDAPHandler ➔ error Error: User not Found
rocketchat_1 | at MethodInvocation.<anonymous> (app/ldap/server/loginHandler.js:60:10)
rocketchat_1 | at packages/accounts-base/accounts_server.js:475:31
rocketchat_1 | at tryLoginMethod (packages/accounts-base/accounts_server.js:1309:14)
rocketchat_1 | at AccountsServer._runLoginHandlers (packages/accounts-base/accounts_server.js:473:22)
rocketchat_1 | at AccountsServer.Accounts._runLoginHandlers (app/lib/server/lib/loginErrorMessageOverride.js:7:35)
rocketchat_1 | at MethodInvocation.methods.login (packages/accounts-base/accounts_server.js:533:31)
rocketchat_1 | at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1771:12)
rocketchat_1 | at packages/ddp-server/livedata_server.js:719:19
rocketchat_1 | at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
rocketchat_1 | at packages/ddp-server/livedata_server.js:717:46
rocketchat_1 | at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
rocketchat_1 | at packages/ddp-server/livedata_server.js:715:46
rocketchat_1 | at new Promise (<anonymous>)
rocketchat_1 | at Session.method (packages/ddp-server/livedata_server.js:689:23)
rocketchat_1 | at packages/ddp-server/livedata_server.js:559:43