How to use the ldapjs.ProtocolError 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.modifyDN(SUFFIX, function(req, res, next){
  var dn = req.dn.toString().replaceSpaces();
  if (!req.newRdn.toString())
    return next(new ldap.ProtocolError('newRdn required'));

  if (!db[dn])
    return next(new ldap.NoSuchObjectError(dn));

  var old = Object.assign({}, db[dn]);
  var newDn = req.newRdn.toString()+","+SUFFIX.replaceSpaces();
  db[newDn] = old;
  var rdnAttribute = req.newRdn.toString().split("=");
  db[newDn][rdnAttribute[0]]=rdnAttribute[1];
  if(req.deleteOldRdn){
      delete db[dn];
  }
  res.end();
  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;
github PhilWaldmann / openrecord / test / ldap / __server.js View on Github external
server.modify(SUFFIX, authorize, function(req, res, next) {
    var dn = req.dn
      .toString()
      .replace(/, /g, ',')
      .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) {