@@ -400,10 +400,10 @@ the following code in as another handler (you'll need a
400
400
` var spawn = require('child_process').spawn; ` at the top of your file):
401
401
402
402
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)
404
404
return next(new ldap.ConstraintViolationError('cn required'));
405
405
406
- if (req.users[req.dn.rdns[0].cn ])
406
+ if (req.users[req.dn.rdns[0].attrs.cn.value ])
407
407
return next(new ldap.EntryAlreadyExistsError(req.dn.toString()));
408
408
409
409
var entry = req.toObject().attributes;
@@ -487,10 +487,10 @@ Let's confirm he got added with an ldapsearch:
487
487
As before, here's a breakdown of the code:
488
488
489
489
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)
491
491
return next(new ldap.ConstraintViolationError('cn required'));
492
492
493
- if (req.users[req.dn.rdns[0].cn ])
493
+ if (req.users[req.dn.rdns[0].attrs.cn.value ])
494
494
return next(new ldap.EntryAlreadyExistsError(req.dn.toString()));
495
495
496
496
var entry = req.toObject().attributes;
@@ -532,13 +532,13 @@ RFC, so appending, removing, or replacing a single attribute is pretty natural.
532
532
Go ahead and add the following code into your source file:
533
533
534
534
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 ])
536
536
return next(new ldap.NoSuchObjectError(req.dn.toString()));
537
537
538
538
if (!req.changes.length)
539
539
return next(new ldap.ProtocolError('changes required'));
540
540
541
- var user = req.users[req.dn.rdns[0].cn ].attributes;
541
+ var user = req.users[req.dn.rdns[0].attrs.cn.value ].attributes;
542
542
var mod;
543
543
544
544
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
594
594
delete it :). Add the following code into your server:
595
595
596
596
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 ])
598
598
return next(new ldap.NoSuchObjectError(req.dn.toString()));
599
599
600
- var userdel = spawn('userdel', ['-f', req.dn.rdns[0].cn ]);
600
+ var userdel = spawn('userdel', ['-f', req.dn.rdns[0].attrs.cn.value ]);
601
601
602
602
var messages = [];
603
603
userdel.stdout.on('data', function(data) {
0 commit comments