Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 97ed088

Browse files
authored
Update guide.md
Dear authors, many thanks for your project. When following your guide, the code crashed when i tried to add a user from the ldif file. I needed the code to change as seen above (the object includes a "attrs" key).
1 parent 3909066 commit 97ed088

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/guide.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,10 @@ the following code in as another handler (you'll need a
400400
`var spawn = require('child_process').spawn;` at the top of your file):
401401

402402
server.add('ou=users, o=myhost', pre, function(req, res, next) {
403-
if (!req.dn.rdns[0].cn)
403+
if (!req.dn.rdns[0].attrs.cn)
404404
return next(new ldap.ConstraintViolationError('cn required'));
405405

406-
if (req.users[req.dn.rdns[0].cn])
406+
if (req.users[req.dn.rdns[0].attrs.cn])
407407
return next(new ldap.EntryAlreadyExistsError(req.dn.toString()));
408408

409409
var entry = req.toObject().attributes;
@@ -487,10 +487,10 @@ Let's confirm he got added with an ldapsearch:
487487
As before, here's a breakdown of the code:
488488

489489
server.add('ou=users, o=myhost', pre, function(req, res, next) {
490-
if (!req.dn.rdns[0].cn)
490+
if (!req.dn.rdns[0].attrs.cn)
491491
return next(new ldap.ConstraintViolationError('cn required'));
492492

493-
if (req.users[req.dn.rdns[0].cn])
493+
if (req.users[req.dn.rdns[0].attrs.cn])
494494
return next(new ldap.EntryAlreadyExistsError(req.dn.toString()));
495495

496496
var entry = req.toObject().attributes;
@@ -532,13 +532,13 @@ RFC, so appending, removing, or replacing a single attribute is pretty natural.
532532
Go ahead and add the following code into your source file:
533533

534534
server.modify('ou=users, o=myhost', pre, function(req, res, next) {
535-
if (!req.dn.rdns[0].cn || !req.users[req.dn.rdns[0].cn])
535+
if (!req.dn.rdns[0].attrs.cn || !req.users[req.dn.rdns[0].attrs.cn])
536536
return next(new ldap.NoSuchObjectError(req.dn.toString()));
537537

538538
if (!req.changes.length)
539539
return next(new ldap.ProtocolError('changes required'));
540540

541-
var user = req.users[req.dn.rdns[0].cn].attributes;
541+
var user = req.users[req.dn.rdns[0].attrs.cn].attributes;
542542
var mod;
543543

544544
for (var i = 0; i < req.changes.length; i++) {
@@ -594,7 +594,7 @@ Delete is pretty straightforward. The client gives you a dn to delete, and you
594594
delete it :). Add the following code into your server:
595595

596596
server.del('ou=users, o=myhost', pre, function(req, res, next) {
597-
if (!req.dn.rdns[0].cn || !req.users[req.dn.rdns[0].cn])
597+
if (!req.dn.rdns[0].attrs.cn || !req.users[req.dn.rdns[0].attrs.cn])
598598
return next(new ldap.NoSuchObjectError(req.dn.toString()));
599599

600600
var userdel = spawn('userdel', ['-f', req.dn.rdns[0].cn]);

0 commit comments

Comments
 (0)