How to use the ldapjs.NoSuchAttributeError 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 flamencist / ldap4net / .test_config / index.js View on Github external
server.bind(SUFFIX, function(req, res, next) {
  console.log(req.dn.toString());
  var dn = req.dn.toString().replaceSpaces();
  if (!db[dn]){
	  return next(new ldap.NoSuchObjectError(dn));
  }
  if (!db[dn].userpassword)
    return next(new ldap.NoSuchAttributeError('userPassword'));

  if (db[dn].userpassword.indexOf(req.credentials) === -1){
    return next(new ldap.InvalidCredentialsError());
  }
  res.end();
  return next();
});
github flamencist / ldap4net / .test_config / index.js View on Github external
server.compare(SUFFIX, authorize, function(req, res, next) {
  var dn = req.dn.toString().replaceSpaces();
  if (!db[dn])
    return next(new ldap.NoSuchObjectError(dn));
  var key = Object.keys(db[dn]).find(_=>_.toLowerCase() === req.attribute);
  if (!key)
    return next(new ldap.NoSuchAttributeError(req.attribute));

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

  res.end(matches);
  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)
    return next()
  })
github flamencist / ldap4net / .test_config / index.js View on Github external
server.modify(SUFFIX, authorize, function(req, res, next) {
  var dn = req.dn.toString().replaceSpaces();
  if (!req.changes.length)
    return next(new ldap.ProtocolError('changes required'));
  if (!db[dn])
    return next(new ldap.NoSuchObjectError(dn));

  var entry = db[dn];

  for (var i = 0; i < req.changes.length; i++) {
    mod = req.changes[i].modification;
    switch (req.changes[i].operation) {
    case 'replace':
      if (!entry[mod.type])
        return next(new ldap.NoSuchAttributeError(mod.type));

      if (!mod.vals || !mod.vals.length) {
        delete entry[mod.type];
      } else {
        entry[mod.type] = mod.vals;
      }

      break;

    case 'add':
      if (!entry[mod.type]) {
        entry[mod.type] = mod.vals;
      } else {
        mod.vals.forEach(function(v) {
          if (entry[mod.type].indexOf(v) === -1)
            entry[mod.type].push(v);
github PhilWaldmann / openrecord / test / ldap / __server.js View on Github external
.toLowerCase()
    if (!req.changes.length) {
      return next(new ldap.ProtocolError('changes required'))
    }
    if (!db[dn]) {
      return next(new ldap.NoSuchObjectError(dn))
    }

    var entry = db[dn]

    for (var i = 0; i < req.changes.length; i++) {
      var mod = req.changes[i].modification
      switch (req.changes[i].operation) {
        case 'replace':
          if (!entry[mod.type]) {
            return next(new ldap.NoSuchAttributeError(mod.type))
          }

          if (!mod.vals || !mod.vals.length) {
            delete entry[mod.type]
          } else {
            entry[mod.type] = mod.vals
          }

          break

        case 'add':
          if (!entry[mod.type]) {
            entry[mod.type] = mod.vals
          } else {
            mod.vals.forEach(function(v) {
              if (entry[mod.type].indexOf(v) === -1) {
github PhilWaldmann / openrecord / test / ldap / __server.js View on Github external
server.bind(SUFFIX, function(req, res, next) {
    var dn = req.dn
      .toString()
      .replace(/, /g, ',')
      .toLowerCase()
    if (!db[dn]) {
      return next(new ldap.NoSuchObjectError(dn))
    }

    if (!db[dn].userpassword) {
      return next(new ldap.NoSuchAttributeError('userPassword'))
    }

    if (db[dn].userpassword.indexOf(req.credentials) === -1) {
      return next(new ldap.InvalidCredentialsError())
    }

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

  if (!db[dn].attributes.userPassword) {
    return next(new ldap.NoSuchAttributeError('userPassword'));
  }

  if (db[dn].attributes.userPassword !== req.credentials) {
    return next(new ldap.InvalidCredentialsError());
  }

  res.end();
  return next();
});