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

Commit da2f977

Browse files
authored
Merge pull request #690 from maltewirz/patch-1
Update guide.md - broken tutorial
2 parents 3909066 + d8c2524 commit da2f977

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

docs/guide.md

Lines changed: 8 additions & 8 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.value])
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.value])
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.value])
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.value].attributes;
542542
var mod;
543543

544544
for (var i = 0; i < req.changes.length; i++) {
@@ -594,10 +594,10 @@ 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.value])
598598
return next(new ldap.NoSuchObjectError(req.dn.toString()));
599599

600-
var userdel = spawn('userdel', ['-f', req.dn.rdns[0].cn]);
600+
var userdel = spawn('userdel', ['-f', req.dn.rdns[0].attrs.cn.value]);
601601

602602
var messages = [];
603603
userdel.stdout.on('data', function(data) {

0 commit comments

Comments
 (0)