Active Directory return ECONNREFUSED when try to get all groups for user in Express framework

41 Views Asked by At

I developing an Express app for an organization, I'm using library activedirectory2 npm for get data from active directory.

I'm using two functions:

  1. Getting the details about the user by username - this function is working fine without problems.
  2. For getting the access groups for a user, I am using function getGroupMembershipForUser and for a specific users I get this error:

"errno": "ECONNREFUSED",
"code": "ECONNREFUSED",
"syscall": "connect",
"address":"****","port":"

This happened for specific users, but not for everybody.

This is the function calling into AD:

const getGroupsByUsername = async (req, res) => {
    try {
        ad.getGroupMembershipForUser(req.ntlm.UserName, function (err, groups) {
            if (err) {
                console.log('ERROR: ' + JSON.stringify(err));
                console.log("ERROR IN GET GROUPS BY USERNAME");
                return;
            }
            if (!groups) {
                console.log('User: ' + req.ntlm.UserName + ' not found.');
            } else { res.json(groups) };

        });
    } catch (err) {
        console.error(err.message);
        res.status(500).send("Server Error");
    }
};

Thanks

0

There are 0 best solutions below