gheeres / node-activedirectory

ActiveDirectory is an Node.js ldapjs client for authN (authentication) and authZ (authorization) for Microsoft Active Directory with range retrieval support for large Active Directory installations.
MIT License
534 stars 146 forks source link

ECONNREFUSED on getGroupMembershipForUser #168

Open Balgorn opened 7 years ago

Balgorn commented 7 years ago

Hi,

today I encountered an interesting problem. When using getGroupMembershipForUser it can occur that for some users the call results into the error "ECONNREFUSED". It seems to depend on the amount of groups a user has. I could track it down to ldap search function, where some of the group searches result in this error. Does anybody have an idea why this happens. For a quick fix i wraped my code in a retry loop:

Here my original code

let service = createActiveDirectory({  
        url: connectUrl(),  
        baseDN: process.env.BASE_DN || defaultConfig.ad.baseDN,  
        bindDN: process.env.BIND_DN,  
        username: process.env.SERVICE_USER,  
        password: process.env.SERVICE_PASS});
                attributes: {
            user: [ 'dn', 'userPrincipalName', 'objectGUID', 'givenName', 'initials', 'sn', 'mail' ],
            group: [ 'cn', 'description' ],
        },
service.getGroupMembershipForUser(user.dn, (err, groups) => {  
...  
});  
CallSign-Filter commented 5 years ago

I am having the same problem, it would be nice to get a fix for this