Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to fetch user & groups #56

Open
akkitech opened this issue Nov 29, 2019 · 7 comments
Open

Unable to fetch user & groups #56

akkitech opened this issue Nov 29, 2019 · 7 comments

Comments

@akkitech
Copy link

akkitech commented Nov 29, 2019

I am using node js activedirectory module for AD authentication and fetching users & groups. Able to authenticate successfully but unable to get users & groups using .findUser(), .findUsers(), .findGroups() methods. I've added few users and a group using ADSI editor in windows 10. Any clue what could be going wrong?

Screenshot of ADSI Editor :

image

Code :

var ActiveDirectory = require('activedirectory2');
var config = {
url: 'ldap://localhost',
baseDN: 'cn=admin,dc=ec2,dc=internal',
username: 'cn=akshay,cn=testContainer,cn=admin,dc=ec2,dc=internal',
password: '123456'
};

var ad = new ActiveDirectory(config);

var username = 'cn=akshay,cn=testContainer,cn=admin,dc=ec2,dc=internal';
var password = '123456';

ad.authenticate(username, password, function (err, auth) {
if (err) {
console.log('ERROR: ' + JSON.stringify(err));
return;
}

if (auth) {
    console.log('Authenticated!');
    ad.findUser({
        dn: "cn=akshay,cn=testContainer,cn=admin,dc=ec2,dc=internal"
    }, function (err, user) {
        if (err) {
            console.log('ERROR: ' + JSON.stringify(err));
            return;
        }

        if (!user) console.log('User: not found.');
        else console.log(JSON.stringify(user));
    });

} else {
    console.log('Authentication failed!');
}
});

Output :

Authenticated!
User: not found.

@jsumners
Copy link
Owner

Have you tried setting a search base and/or scope?

@akkitech
Copy link
Author

Yes, passed baseDN as cn=testContainer,cn=admin,dc=ec2,dc=internal still no results.

@jurjendijkstra
Copy link

Perhaps a dumb answer, but I wonder if things are case sensitive and would try, just for curiosity:
"cn=TestContainer,cn=ADMIN,dc=EC2,dc=INTERNAL" same case as in the ADSI editor screenshot

@akkitech
Copy link
Author

Thank you @jurjendijkstra , Already tried with upper case but no luck.

@jurjendijkstra
Copy link

Hmm sorry. Another guess: you are passing an object { dn: "..."} to findUser but according to the doc you should pass a string, and the value of that string may be either the sAMAccountName, userPrincipalName or dn. Like this:
ad.findUser("cn=akshay,cn=testContainer,cn=admin,dc=ec2,dc=internal", callback)

@akkitech
Copy link
Author

akkitech commented Dec 2, 2019

Thank you @jurjendijkstra , Tried with a DN string still no luck.

Can you help me in finding my sAMAccountName / userPrincipalName in ADSI editor? I am unable to locate this option.

@akkitech
Copy link
Author

akkitech commented Dec 2, 2019

OR sAMAccountName is just the name that was used while adding a new user in ADSI? i.e akshay in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants