How do I ask LDAP "Any groups starting with Foo*, what groups am I a member of?" with the response being as simple as possible.
By issuing a LDAP query as you normally would as shown here.
For example, I want to find all records that have a displayName
of BUILDING_FOO
, but I also want to exclude certain records. So my LDAP query would look something like:
(&(displayName=BUILDING_*)(!(cn=ILM_BUILDING_EXAMPLE)))
So for your requirement, let's say your base
DN is OU=GROUPS,DC=example,DC=com
. Then we'll say the group your looking for has an attribute of groupName
so your LDAP query could be as simple as:
(groupName=Foo*)
As for LDAPjs, it would look something like:
// Setup/configuration of LDAPjs is omitted, see official docs.
const options = {
filter: '(groupName=Foo*)',
scope: 'sub'
}
ldapClient.search('OU=GROUPS,DC=example,DC=com', options, (error, result) => {
if (error) {
debug(`Unable to search for groups. (${error.message})`)
process.exit(1)
}
result.on('searchEntry', entry => {
// Do something with the entry
console.log(entry)
})
})