提取所有活动目录用户的属性
我想使用 Node JS 提取活动目录用户的某些属性(例如电子邮件、电话等)。根据此 文档,我能够使用此提取某个用户的属性一段代码:
var ActiveDirectory = require('activedirectory');
var ad = new ActiveDirectory({ url: 'ldap://domain.com',
baseDN: 'dc=domain,dc=com',
username: '[email protected]',
password: 'password',
attributes: {
user: [ 'givenName', 'mail', 'mobile' ],
// group: [ 'anotherCustomAttribute', 'objectCategory' ]
}
});
var sAMAccountName = 'desiredUsername';
ad.findUser(sAMAccountName, function(err, user) {
if (err) {
console.log('ERROR: ' +JSON.stringify(err));
return;
}
if (! user) console.log('User: ' + sAMAccountName + ' not found.');
else console.log(JSON.stringify(user));
});
现在我想知道如何提取所有活动目录用户所需的属性,考虑到某些用户没有组名。
是否可以提取活动目录中所有现有的 sAMAccountName
并以这种方式提取每个用户的属性?
I want to extract certain attributes (such as email, phone, etc.) of an active directory users using Node JS. According to this documentation, I was able to extract the attributes of a certain user using this piece of code:
var ActiveDirectory = require('activedirectory');
var ad = new ActiveDirectory({ url: 'ldap://domain.com',
baseDN: 'dc=domain,dc=com',
username: '[email protected]',
password: 'password',
attributes: {
user: [ 'givenName', 'mail', 'mobile' ],
// group: [ 'anotherCustomAttribute', 'objectCategory' ]
}
});
var sAMAccountName = 'desiredUsername';
ad.findUser(sAMAccountName, function(err, user) {
if (err) {
console.log('ERROR: ' +JSON.stringify(err));
return;
}
if (! user) console.log('User: ' + sAMAccountName + ' not found.');
else console.log(JSON.stringify(user));
});
Now I want to know how I can extract the desired attributes of all active directory users, considering the fact that some users don't have a groupName.
Is it possible to extract all existing sAMAccountName
in the active directory and extract the attributes of each user this way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
findUsers
而不是findUser.
不包含过滤器,它将使用查找所有用户的默认过滤器:
Use
findUsers
instead offindUser
.Don't include a filter, and it'll use the default filter of finding all users: