How to use the ldapjs.Control 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 gheeres / node-activedirectory / lib / activedirectory.js View on Github external
}

  var results = [];
  
  var controls = opts.controls || (opts.controls = []);
  // Add paging results control by default if not already added.
  if (!_.any(controls, function(control) { return(control instanceof ldap.PagedResultsControl); })) {
    log.debug('Adding PagedResultControl to search (%s) with filter "%s" for %j',
              baseDN, truncateLogOutput(opts.filter), _.any(opts.attributes) ? opts.attributes : '[*]');
    controls.push(new ldap.PagedResultsControl({ value: { size: defaultPageSize } }));
  }
  if (opts.includeDeleted) {
    if (!_.any(controls, function(control) { return(control.type === '1.2.840.113556.1.4.417'); })) {
      log.debug('Adding ShowDeletedOidControl(1.2.840.113556.1.4.417) to search (%s) with filter "%s" for %j',
                baseDN, truncateLogOutput(opts.filter), _.any(opts.attributes) ? opts.attributes : '[*]');
      controls.push(new ldap.Control({ type: '1.2.840.113556.1.4.417', criticality: true }));
    }
  }

  log.debug('Querying active directory (%s) with filter "%s" for %j',
            baseDN, truncateLogOutput(opts.filter), _.any(opts.attributes) ? opts.attributes : '[*]');
  client.search(baseDN, getLdapOpts(opts), controls, function onSearch(err, res) {
    if (err) {
      if (callback) callback(err);
      return;
    }

    res.on('searchEntry', onSearchEntry);
    res.on('searchReference', onReferralChase);
    res.on('error', function(err) { onClientError(err, res); });
    res.on('end', function(result) {
      isDone = true; // Flag that the primary query is complete
github PhilWaldmann / openrecord / lib / stores / ldap / exec.js View on Github external
this.onFind(function(options, data) {
      var chain = this

      if (
        options.filter &&
        options.filter.filters &&
        options.filter.filters.length === 0
      ) {
        options.filter = null
      }

      options.controls = options.controls || []

      for (var i = 0; i < options.controls.length; i++) {
        if (!(options.controls[i] instanceof ldap.Control)) {
          options.controls[i] = new ldap.Control(options.controls[i])
        }
      }

      return new Promise(function(resolve, reject) {
        chain.connection.search(
          options.root,
          options,
          options.controls,
          function(err, res) {
            debug(
              'Search ' +
                options.root +
                ' (Scope=' +
                options.scope +
                ', Filter=' +
                options.filter.toString() +