node-activedirectory
node-activedirectory copied to clipboard
getGroupMembershipForUser and findUsers errors in case the CN section of distinguishedName attribute value contains special characters
Based on my testing, in case the CN section of the user distinguishedName attribute value contains (a) more than one comma character , (b) a plus sign character + (c) a greater than character > (d) a less than character < (e) a semicolon character ; (f) the equals character = (g) the asterisk character *
then the following node-activedirectory functions return no associated group objects even in the event that the user is a member of one or more groups -
(1) getGroupMembershipForUser(opts, userPrincipalName, callback)
(2) findUsers(opts, callback)
case where includeMembership
is a property of the opts object
I think this can be fixed in parseDistinguishedName method. I happened to stumble on the same problem, but with bracket characters ( and ).
Changing the method to something like this helped me:
function parseDistinguishedName(dn) {
log.trace('parseDistinguishedName(%s)', dn);
if (! dn) return(dn);
dn = dn.replace(/"/g, '\\"');
dn = dn.replace(/\(/g, '\\(');
dn = dn.replace(/\)/g, '\\)');
return(dn.replace('\\,', '\\\\,'));
}
I think this can be fixed in parseDistinguishedName method. I happened to stumble on the same problem, but with bracket characters ( and ).
Changing the method to something like this helped me:
function parseDistinguishedName(dn) { log.trace('parseDistinguishedName(%s)', dn); if (! dn) return(dn); dn = dn.replace(/"/g, '\\"'); dn = dn.replace(/\(/g, '\\('); dn = dn.replace(/\)/g, '\\)'); return(dn.replace('\\,', '\\\\,')); }
Thank you this helped me very much