Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function listUsers(req, res, next) {
assert([ 2, 3 ].indexOf(keys(req.rdns).length) !== null);
assert('teleport' === req.rdns.o);
assert('users' === req.rdns.ou);
var layer = req.bindLayer;
assert(layer);
// If searching for a specific user
var uid = req.rdns.uid;
if ( uid ) {
req.filter = new ldap.AndFilter({
filters: [req.filter, new ldap.EqualityFilter({attribute: 'uid', value: uid})]
});
}
var resultCount = 0;
function end(err) {
log.info({requestId: req.logId, command: 'listUsers', resultCount: resultCount}, "Sent %d users", resultCount);
res.end();
next(err);
}
dataStore.layerUsers(layer).on('user', function(user) {
var attributes = clone(user);
// Apply some defaults
if ( !attributes.uid ) attributes.uid = user.uid;
if ( !attributes.cn ) attributes.cn = user.uid;
binary: function(attr, value, options) {
value = this.definition.cast(attr, value, 'write', this)
options.filter.filters.push(
new ldap.EqualityFilter({ attribute: attr, value: value })
)
}
}
function(attr, value, options) {
options.filter.filters.push(
new ldap.NotFilter({
filter: new ldap.EqualityFilter({ attribute: attr, value: value })
})
)
},
{
defaultMethod: function(attr, value, options) {
value = this.definition.cast(attr, value, 'write', this)
options.filter.filters.push(
new ldap.EqualityFilter({ attribute: attr, value: value })
)
},