Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
});
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;
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) {