I'm getting "No Such Object" error when I try to modify a group, even though the DN provided is correct.
I added Bunyan to inspect logs, and I could see from the response that object was empty.
const client = ldap.createClient({
url: 'LDAPS:/xxx',
tlsOptions: {
rejectUnauthorized: true,
cert: fs.readFileSync('xx.pem'),
ca: fs.readFileSync('xxx.pem'),
},
reconnect: false,
log: new Bunyan({
name: 'ldapjs',
component: 'client',
stream: process.stderr,
level: 'trace',
}),
});
Response:
{
"name": "ldapjs",
"component": "client",
"hostname": "x",
"pid": 33960,
"clazz": "Client",
"ldap_id": "x",
"level": 10,
"msg": "sending request {\"messageId\":3,\"protocolOp\":102,\"type\":\"ModifyRequest\",\"object\":{},\"changes\":[{\"operation\":\"add\",\"modification\":{\"type\":\"member\",\"values\":[\"CN=xx\"]}}],\"controls\":[]}",
"time": "2023-08-02T11:58:39.461Z",
"v": 0
}
Function for modifying:
client.modify('cn=foo,dc=example,dc=com', change, (err) => {
if (err) {
console.log(err);
reject(new Error(err.message));
} else {
console.log('la til i gruppe %j', null);
resolve(null);
}
});
I solved it by manually editing the ensureDN function in the \node_modules\ldapjs\lib\client\client.js file from:
function ensureDN(input) {
if (DN.isDn(input)) {
return DN
} else if (typeof (input) === 'string') {
return DN.fromString(input)
} else {
throw new Error('invalid DN')
}
}
To:
function ensureDN(input) {
if (DN.isDn(input)) {
return DN
} else if (typeof (input) === 'string') {
return input // instead of DN.fromString()
} else {
throw new Error('invalid DN')
}
}
Is this a known issue, or am I missing something?
I'm getting "No Such Object" error when I try to modify a group, even though the DN provided is correct.
I added
Bunyanto inspect logs, and I could see from the response thatobjectwas empty.Response:
{ "name": "ldapjs", "component": "client", "hostname": "x", "pid": 33960, "clazz": "Client", "ldap_id": "x", "level": 10, "msg": "sending request {\"messageId\":3,\"protocolOp\":102,\"type\":\"ModifyRequest\",\"object\":{},\"changes\":[{\"operation\":\"add\",\"modification\":{\"type\":\"member\",\"values\":[\"CN=xx\"]}}],\"controls\":[]}", "time": "2023-08-02T11:58:39.461Z", "v": 0 }Function for modifying:
I solved it by manually editing the ensureDN function in the
\node_modules\ldapjs\lib\client\client.jsfile from:To:
Is this a known issue, or am I missing something?