@@ -403,10 +403,10 @@ the following code in as another handler (you'll need a
403
403
` var spawn = require('child_process').spawn; ` at the top of your file):
404
404
405
405
server.add('ou=users, o=myhost', pre, function(req, res, next) {
406
- if (!req.dn.rdns[0].cn)
406
+ if (!req.dn.rdns[0].attrs. cn)
407
407
return next(new ldap.ConstraintViolationError('cn required'));
408
408
409
- if (req.users[req.dn.rdns[0].cn ])
409
+ if (req.users[req.dn.rdns[0].attrs.cn.value ])
410
410
return next(new ldap.EntryAlreadyExistsError(req.dn.toString()));
411
411
412
412
var entry = req.toObject().attributes;
@@ -490,10 +490,10 @@ Let's confirm he got added with an ldapsearch:
490
490
As before, here's a breakdown of the code:
491
491
492
492
server.add('ou=users, o=myhost', pre, function(req, res, next) {
493
- if (!req.dn.rdns[0].cn)
493
+ if (!req.dn.rdns[0].attrs. cn)
494
494
return next(new ldap.ConstraintViolationError('cn required'));
495
495
496
- if (req.users[req.dn.rdns[0].cn ])
496
+ if (req.users[req.dn.rdns[0].attrs.cn.value ])
497
497
return next(new ldap.EntryAlreadyExistsError(req.dn.toString()));
498
498
499
499
var entry = req.toObject().attributes;
@@ -535,13 +535,13 @@ RFC, so appending, removing, or replacing a single attribute is pretty natural.
535
535
Go ahead and add the following code into your source file:
536
536
537
537
server.modify('ou=users, o=myhost', pre, function(req, res, next) {
538
- if (!req.dn.rdns[0].cn || !req.users[req.dn.rdns[0].cn ])
538
+ if (!req.dn.rdns[0].attrs. cn || !req.users[req.dn.rdns[0].attrs.cn.value ])
539
539
return next(new ldap.NoSuchObjectError(req.dn.toString()));
540
540
541
541
if (!req.changes.length)
542
542
return next(new ldap.ProtocolError('changes required'));
543
543
544
- var user = req.users[req.dn.rdns[0].cn ].attributes;
544
+ var user = req.users[req.dn.rdns[0].attrs.cn.value ].attributes;
545
545
var mod;
546
546
547
547
for (var i = 0; i < req.changes.length; i++) {
@@ -597,10 +597,10 @@ Delete is pretty straightforward. The client gives you a dn to delete, and you
597
597
delete it :). Add the following code into your server:
598
598
599
599
server.del('ou=users, o=myhost', pre, function(req, res, next) {
600
- if (!req.dn.rdns[0].cn || !req.users[req.dn.rdns[0].cn ])
600
+ if (!req.dn.rdns[0].attrs. cn || !req.users[req.dn.rdns[0].attrs.cn.value ])
601
601
return next(new ldap.NoSuchObjectError(req.dn.toString()));
602
602
603
- var userdel = spawn('userdel', ['-f', req.dn.rdns[0].cn ]);
603
+ var userdel = spawn('userdel', ['-f', req.dn.rdns[0].attrs.cn.value ]);
604
604
605
605
var messages = [];
606
606
userdel.stdout.on('data', function(data) {
0 commit comments