Wednesday 3 May 2017

ldapjs, how to delete attribute

I want to use Node.js ldapjs client api #modify to delete an attribute of an LDAP entry.

Via shell and ldapmodify ... -f removeAttribute.ldif it works, using the following ldif file:

dn: uid=user,dc=test
changetype: modify
delete: myAttribute

Following the ldapjs documentation I have to use operation 'delete' and to add the attribute to modification (...Deletes the attribute (and all values) referenced in modification...).

If I try to do that using ldapjs, I get errors.

let dn = 'uid=user,dc=test';
let changes = [];
let change = { operation : 'delete', modification: { myAttribute: null } ;
client.modify(dn, changes, err => { ... });

... leads to error Cannot read property 'toString' of null

let dn = 'uid=user,dc=test';
let changes = [];
let change = { operation : 'delete', modification: { myAttribute: oldValue } };
client.modify(dn, changes, err => { ... });

... leads to InappropriateMatchingError

So my question: how I have to prepare the array changes, if I want to delete an attribute?



via Manfred Steiner

No comments:

Post a Comment