node-activedirectory icon indicating copy to clipboard operation
node-activedirectory copied to clipboard

getGroupMembershipForUser and findUsers errors in case the CN section of distinguishedName attribute value contains special characters

Open achawla5000 opened this issue 7 years ago • 2 comments

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

achawla5000 avatar Jun 23 '17 22:06 achawla5000

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('\\,', '\\\\,'));
}

jurkan avatar Sep 28 '20 21:09 jurkan

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

nandsfordays avatar May 16 '23 17:05 nandsfordays