finduser and getGroupMembershipForUser callback params are both undefined
When I'm calling findUser() or getGroupMembershipForUser, the callback params(err, user, groups) are always undefined.
I am able to authenticae a single user.
I am passing the username as 'domaniname\username'. I didn't see any difference when passing just the username without domain name. I am using the version 0.7.2.
Code var adConfig = { url: 'ldap://domain', baseDN: 'dc=domain,dc=net'} var ad = new activedirectory(adConfig); ad.opts.bindDN = 'domain\username'; ad.opts.bindCredentials = 'password';
ad.getGroupMembershipForUser('domain\username', function (err, groups) {
if (err) {
done(err);
}
if (! user) done('User not found.');
else done(JSON.stringify(groups));
});
Did you try running the example code provided. Also try using a userPrincipalName instead of a sAMAccountName, although either should work.
var sAMAccountName = '[email protected]';
var ad = new ActiveDirectory(config);
ad.getGroupMembershipForUser(sAMAccountName, function(err, groups) {
if (err) {
console.log('ERROR: ' +JSON.stringify(err));
return;
}
if (! groups) console.log('User: ' + sAMAccountName + ' not found.');
else console.log(JSON.stringify(groups));
});
Note: The code sample you provided has some errors. 'user' is not defined, etc. I'd recommend to do some quick debugging and testing outside of your 'done' method. Simple console.log messages are usually sufficient in a pinch.
I have copied the above sample code with userPrincipalName and sAMAccountName combinations and keep getting undefined for err and groups object.
The only line i have changed is giving different account name.
Please double check your configuration:
var adConfig = { url: 'ldap://domain',
baseDN: 'dc=domain,dc=net'}
var ad = new activedirectory(adConfig);
ad.opts.bindDN = 'domain\username';
ad.opts.bindCredentials = 'password';
The username / password should be configured as:
var ActiveDirectory = require('activedirectory');
var config = { url: 'ldap://dc.domain.com',
baseDN: 'dc=domain,dc=com',
username: '[email protected]',
password: 'password' }
var ad = new ActiveDirectory(config);
Do not specify them as ad.opts.bindDN, ad.opts.bindCredentials, etc. unless you are doing advanced operations and trying to work with the underlying ldapjs directly.
I am now able to retrieve the groups without passing the domainname in userPrincipalName (i.e . fzurit instead of 'domainname\fzurit') for the users in the root domain.
Is there a way that i can pass the domain name because our AD has sub-domains( for ex : development domain, qa domain) under the root domain and if we don't pass the domainname the user wouldn't be able to found.
aah..i got it working by changing the adconfig parameters (url and baseDN) based on the domain the user belongs to and now i am able to retrieve the groups..
One thing i noticed though is i am not seeing the SIDs for the groups. Is there a way to get the SID for the user and the groups the user belongs to??
By default, the group membership information containing the SID is not included. If I recall, you can change the default attributes that are returned for a group to include the SID.
Keep in mind that if you need the binary version of the SID, it requires specially processing. See the following issue for more information. #15
Hi, I want to get ObjectSids in string. I see raw has all the entries as ByteArray and entry has many of them as string. I was looking for the logic to convert my ObjectSid to string format. Please guide.
If I recall, the object sids should automatically be included / converted to strings when the attribute is specified. Just specify the attribute you want into the defaults or specify it via custom opts.
I am passing
attributes: {
group: ['objectSid', 'sAMAccountName']
} as part of config and I do get these values back but ObjectSid comes back as byte array.
I used entryParser to check if I get ObjectSid as string but when I debug, raw and entry both has it as binary data.
entryParser: function customEntryParser(entry, raw, callback) { if (raw.hasOwnProperty("objectSid")) { console.log(raw.objectSid.toString()); } if (entry.hasOwnProperty("objectSid")) { console.log(entry.objectSid.toString()); } callback(entry); }
Hi, have something similar here. Authentification works fine, but no other function... Especially I am interested in getting Groups the user belongs to, with a getGroupMemebrshipForUser function. My code look like:
const ActiveDirectory = require("activedirectory"); const ad = new ActiveDirectory({
url: "ldaps://domain.name.com",
baseDN: "DC=domain,DC=name,DC=com",
tlsOptions: { rejectUnauthorized: false },
username: [email protected],
password: "userPass",
});
var sAMAccountName = "[email protected]"; ad.getGroupMembershipForUser(sAMAccountName, function (err, groups) {
if (err) {
console.log("ERROR: " + JSON.stringify(err));
return;
}
if (!groups) console.log("User: " + sAMAccountName + " not found.");
else console.log(JSON.stringify(groups));
});
I am getting error like :
ERROR: {"lde_message":"No Such Object","lde_dn":"DC=name,DC=com"}
Basically, this error repeats with every other function I try to use from the library, except authentification.
Any Idea what can be wrong here?
Hi, have something similar here. Authentification works fine, but no other function... Especially I am interested in getting Groups the user belongs to, with a getGroupMemebrshipForUser function. My code look like:
const ActiveDirectory = require("activedirectory"); const ad = new ActiveDirectory({
url: "ldaps://domain.name.com",
baseDN: "DC=domain,DC=name,DC=com",
tlsOptions: { rejectUnauthorized: false },
username:
[email protected],password: "userPass",
});
var sAMAccountName = "[email protected]"; ad.getGroupMembershipForUser(sAMAccountName, function (err, groups) {
if (err) {
console.log("ERROR: " + JSON.stringify(err)); return;}
if (!groups) console.log("User: " + sAMAccountName + " not found.");
else console.log(JSON.stringify(groups));
});
I am getting error like :
ERROR: {"lde_message":"No Such Object","lde_dn":"DC=name,DC=com"}
Basically, this error repeats with every other function I try to use from the library, except authentification.
Any Idea what can be wrong here?
Same error here