How to use the ldapjs.EntryAlreadyExistsError 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 PhilWaldmann / openrecord / test / ldap / __server.js View on Github external
server.add(SUFFIX, authorize, function(req, res, next) {
    var dn = req.dn
      .toString()
      .replace(/, /g, ',')
      .toLowerCase()
    if (db[dn]) {
      return next(new ldap.EntryAlreadyExistsError(dn))
    }

    db[dn] = req.toObject().attributes

    res.end()
    return next()
  })
github flamencist / ldap4net / .test_config / index.js View on Github external
server.add(SUFFIX, authorize, function(req, res, next) {
  try{
    var dn = req.dn.toString().replaceSpaces();
    if(!dn.endsWith(SUFFIX.replaceSpaces())){
      dn+=","+SUFFIX.replaceSpaces();
    }
    if (db[dn])
      return next(new ldap.EntryAlreadyExistsError(dn));

    var attributes =  req.toObject().attributes;
    if(dn.startsWith("cn=")){
      attributes["cn"]=dn.match(/cn=([^,]*),/)[1];
    }
    db[dn] = attributes;
    res.end();
    return next();
  }catch(e){
    return next(new ldap.LdapError(e.toString()));
  }
});