How to use the ldapjs.NoSuchObjectError 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 4minitz / 4minitz / tests / support / ldap-server.js View on Github external
let dn = req.dn.toString(),
        normalizedDn = dn.replace(/ /g, ''),
        password = req.credentials;

    console.log(dn, normalizedDn, password);

    let matchingUsers = _.filter(users, user => normalizedDn == user.dn);

    console.log(matchingUsers);

    if (matchingUsers.length > 1) {
        return next(new ldap.UnwillingToPerformError());
    }

    if (matchingUsers.length == 0) {
        return next(new ldap.NoSuchObjectError(dn));
    }

    let user = matchingUsers[0];

    if (user.password != password) {
        return next(new ldap.InvalidCredentialsError());
    }

    res.end();
    return next();
});
github PhilWaldmann / openrecord / test / ldap / __server.js View on Github external
server.compare(SUFFIX, authorize, function(req, res, next) {
    var dn = req.dn
      .toString()
      .replace(/, /g, ',')
      .toLowerCase()
    if (!db[dn]) {
      return next(new ldap.NoSuchObjectError(dn))
    }

    if (!db[dn][req.attribute]) {
      return next(new ldap.NoSuchAttributeError(req.attribute))
    }

    var matches = false
    var vals = db[dn][req.attribute]
    for (var i = 0; i < vals.length; i++) {
      if (vals[i] === req.value) {
        matches = true
        break
      }
    }

    res.end(matches)
github flamencist / ldap4net / .test_config / index.js View on Github external
server.del(SUFFIX, authorize, function(req, res, next) {
  var dn = req.dn.toString().replaceSpaces();
  if (!db[dn])
    return next(new ldap.NoSuchObjectError(dn));

  delete db[dn];

  res.end();
  return next();
});
github PhilWaldmann / openrecord / test / ldap / __server.js View on Github external
server.modifyDN(SUFFIX, function(req, res, next) {
    var dn = req.dn
      .toString()
      .replace(/, /g, ',')
      .toLowerCase()
    var newDn = req.newRdn.toString() + ', ' + req.dn.parent().toString()

    if (!db[dn]) {
      return next(new ldap.NoSuchObjectError(req.newSuperior.toString()))
    }

    if (req.newSuperior) {
      if (!db[req.newSuperior.toString().replace(/, /g, ',')]) {
        return next(new ldap.NoSuchObjectError(req.newSuperior.toString()))
      }

      newDn = req.newRdn.toString() + ', ' + req.newSuperior.toString()
    }

    newDn = newDn.replace(/, /g, ',').toLowerCase()

    db[newDn] = db[dn]

    if (req.deleteOldRdn) {
      delete db[dn]
    }

    res.end()
  })
github marklogic-community / marklogic-samplestack / appserver / node-express / lib / ldapWorker.js View on Github external
server.compare(SUFFIX, authorize, function (req, res, next) {
  var dn = req.dn.toString();
  if (!db[dn]) {
    return next(new ldap.NoSuchObjectError(dn));
  }

  if (!db[dn][req.attribute]) {
    return next(new ldap.NoSuchAttributeError(req.attribute));
  }

  var matches = false;
  var vals = db[dn][req.attribute];
  for (var i = 0; i < vals.length; i++) {
    if (vals[i] === req.value) {
      matches = true;
      break;
    }
  }

  res.end(matches);
github trueaccord / FallingRock / server.js View on Github external
server.bind('', authorize, function(req, res, next) {
        var db = getCurrentDB();
        var dn = req.dn.toString();
        if (!db[dn] || db[dn].type !== 'user') {
            return next(new ldap.NoSuchObjectError(dn));
        }
        var u = db[dn].original;
        okta.checkUserAndPassword(u.profile.login, req.credentials).then(
            function(r) {
                res.end();
                next();
            },
            function(r) {
                next(new ldap.InvalidCredentialsError(dn));
            });
    });
github trueaccord / FallingRock / server.js View on Github external
server.bind(config.admin.username, function(req, res, next) {
        if (!req.dn.equals(config.admin.username)) {
            winston.info('Got a bind for a child of the admin user: %s', req.dn.toString());
            return next(new ldap.NoSuchObjectError(req.dn.toString()));
        }
        if (req.credentials !== config.admin.password) {
            winston.info('Got invalid credentials for admin user.');
            return next(new ldap.InvalidCredentialsError());
        }
        res.end();
        return next();
    });
github codingchili / kibana-mithril / src / authentication / ldap.js View on Github external
result.on('end', () => {
                if (!found) {
                    callback(new LDAP.NoSuchObjectError());
                }
            });
        });