I'm using ldapauth-fork <https://github.com/vesse/node-ldapauth-fork> to auth against an Active Directory domain. I grab the groups that the user is a member of to later provide access. While cleaning them up i get the below error
[TypeError: Cannot read property 'forEach' of undefined] When I first start node the issue doesn't present itself, but after several hours It starts to appear. I started to log usr.memberOf but when I did issue went away, perhaps I haven't been patient enough and it eventually will. This has been working for several months without issues. I've recently made several changes to the service but really only one to this specific area of code. I've removed... config = {cached: true} Heres what I believe is the relevant snip var LdapAuth = require('ldapauth-fork'); // These are the searchAttributes: ['givenName', 'sn', 'mail', 'memberOf'] var roles = ['ADGroup1','ADGroup2','ADGroup3','ADGroup4'] function sanitizeGroup(grp) { var group = []; grp.forEach(function(g){ var cg = g.split(',')[0].replace('CN=',''); if (roles.indexOf(cg) > -1) { group.push(cg); } }); return group; }; function sanitizeUser(usr) { var user = { fname : usr.givenName, lname : usr.sn, email : usr.mail, groups : sanitizeGroup(usr.memberOf) }; return user; }; /* ad.auth = function (username, password, callback) { var ldap = new LdapAuth(config); ldap.authenticate(username, password, function (err, user) { if (err) { console.log("LDAP auth error: %s", err); callback(err); } if (user) { callback(err, sanitizeUser(user)); } ldap.close(); }); }; */ /*The user looks like this */ var user = { givenName: "joe", sn: "blow", mail: "jb...@domain.com", memberOf:['ADGroup3','ADGroup4','ADGroup5','ADGroup6'] } console.log(sanitizeUser(user)); I'm new to node and js so its likely I've flubbed something here. Any and all help would be appreciated. -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. To post to this group, send email to nodejs@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/106170e0-b137-43b0-a35f-9528682bbe74%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.