From b94a66916efa726013dfe59e3677cd78b3db7a2f Mon Sep 17 00:00:00 2001 From: Patrick Mooney Date: Tue, 29 Jul 2014 10:09:03 -0500 Subject: [PATCH] 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. --- bin/ldapjs-add | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/ldapjs-add b/bin/ldapjs-add index 86c0a1d..a3f5174 100755 --- a/bin/ldapjs-add +++ b/bin/ldapjs-add @@ -6,6 +6,7 @@ var fs = require('fs'); var path = require('path'); var dashdash = require('dashdash'); +var vasync = require('vasync'); var ldap = require('../lib/index'); var Logger = require('bunyan'); @@ -170,9 +171,17 @@ client.bind(parsed.binddn, parsed.password, function (err, res) { client.unbind(function () { return; }); } - parsed.file.forEach(function (entry) { - var dn = entry.dn; - delete entry.dn; - client.add(dn, entry, callback); + vasync.forEachPipeline({ + inputs: parsed.file, + func: function (entry, cb) { + var dn = entry.dn; + delete entry.dn; + client.add(dn, entry, cb); + } + }, function (err2, res2) { + if (err2) { + perror(err2); + } + client.unbind(function () { return; }); }); });