In my node application, I have an use case in which I need to authenticate the LDAP users belonging to a specific group only. If the user does not belong to the mentioned group, authentication should fail.
I am using the library ldapauth-fork for LDAP authentication.
I tried various approaches for the filters, but none of them are working as expected. Below are the attempts that I tried:
let ldapConnector = new LdapAuth (
{
url : config.ldap.url,
bindDN : config.ldap.bindDN,
adminPassword : config.ldap.adminPassword,
searchBase : config.ldap.searchBase,
searchFilter : "(&(sAMAccountName=testUser)(memberOf=testGroup))",
cache : true,
includeRaw : true,
log : logger
}
);
For this configuration, I always get no such user: "testuser"
even if the user is member of the testGroup
group.
let ldapConnector = new LdapAuth (
{
url : config.ldap.url,
bindDN : config.ldap.bindDN,
adminPassword : config.ldap.adminPassword,
searchBase : config.ldap.searchBase,
searchFilter : "(sAMAccountName=testuser)",
groupSearchFilter : "(member=testGroup)"`
cache : true,
includeRaw : true,
log : logger
}
);
For this configuration, the authentication is always successful, even if the group name is a random string.
So, what should be the correct filter string to make the authentication work?