How to use the ldapjs.AndFilter function in ldapjs

To help you get started, we’ve selected a few ldapjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github conjurinc / teleport / lib / ldap / listUsers.js View on Github external
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;
github openstf / stf / lib / util / ldaputil.js View on Github external
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)
github PhilWaldmann / openrecord / lib / stores / ldap / exec.js View on Github external
getExecOptions: function() {
    return {
      filter: new ldap.AndFilter({ filters: [] })
    }
  },
github PhilWaldmann / openrecord / lib / stores / ldap / helper.js View on Github external
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];