Process entries sequentially in ldapjs-add

This more closely mimics the behavior of ldapadd when it processes LDIF
entries in the order they are listed in the file.
This commit is contained in:
Patrick Mooney 2014-07-29 10:09:03 -05:00
parent de16802a16
commit b94a66916e
1 changed files with 13 additions and 4 deletions

View File

@ -6,6 +6,7 @@ var fs = require('fs');
var path = require('path'); var path = require('path');
var dashdash = require('dashdash'); var dashdash = require('dashdash');
var vasync = require('vasync');
var ldap = require('../lib/index'); var ldap = require('../lib/index');
var Logger = require('bunyan'); var Logger = require('bunyan');
@ -170,9 +171,17 @@ client.bind(parsed.binddn, parsed.password, function (err, res) {
client.unbind(function () { return; }); client.unbind(function () { return; });
} }
parsed.file.forEach(function (entry) { vasync.forEachPipeline({
var dn = entry.dn; inputs: parsed.file,
delete entry.dn; func: function (entry, cb) {
client.add(dn, entry, callback); var dn = entry.dn;
delete entry.dn;
client.add(dn, entry, cb);
}
}, function (err2, res2) {
if (err2) {
perror(err2);
}
client.unbind(function () { return; });
}); });
}); });