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;
function tryFind(client) {
var resolver = Promise.defer()
var query = {
scope: options.search.scope
, filter: new ldap.AndFilter({
filters: [
new ldap.EqualityFilter({
attribute: 'objectClass'
, value: options.search.objectClass
})
, new ldap.EqualityFilter({
attribute: options.search.field
, value: username
})
]
})
}
client.search(options.search.dn, query, function(err, search) {
if (err) {
return resolver.reject(err)
getExecOptions: function() {
return {
filter: new ldap.AndFilter({ filters: [] })
}
},
exports.applyConditions = function(conditions, options){
if(options.filter) return;
var tmp = options.filter = new ldap.AndFilter();
for(var i = 0; i < conditions.length; i++){
if(conditions[i].type == 'hash'){
var name = conditions[i].field;
var value = conditions[i].value;
var operator = conditions[i].operator;
if(value instanceof Array && value.length === 0){
value = null;
}
if(value === null && operator !== 'is not'){
operator = 'is';
}
if(!(value instanceof Array) || UNMODIFIED_OPERATORS.indexOf(operator) !== -1) value = [value];