Comments (12)
console.log(req.dn)
should be console.log(req.dn.toString())
.
from node-ldapjs.
Please provide a minimal reproducible example. Doing so will help us diagnose your issue. It should be the bare minimum code needed to trigger the issue, and easily runnable without any changes or extra code.
You may use a GitHub repository to host the code if it is too much to fit in a code block (or two).
Aside from that, my best suggestion would be to step through your application with a debugger to determine what triggers the error.
from node-ldapjs.
This is the example I've been using from the guide. It's mostly copied from there as I'm not sure how it all works.
https://github.com/Ketho/ldapjs_example/blob/master/minimal_example.js
Stepping through the application with a debugger seems a bit daunting but I will try that.
Oh I forgot to include the user.ldif to the repository
from node-ldapjs.
Please review the links and body of my previous message. Your example is relying on external resources and requires extra effort to use.
from node-ldapjs.
I'll be honest, I don't know anything about LDAP, that's why I'm following the guide. I have literally no idea how to not rely on the external resources like child_process or any unneeded code from the guide. The /etc/passwd
file is the default one from Ubuntu/Debian.
from node-ldapjs.
LDAP knowledge really doesn't factor in to creating a minimal reproduction. You should supply the code, the code should reference a fixture (e.g. a passwd
file with fake data), and invoke the error state with node index.js
or npm start
.
from node-ldapjs.
Okay, when I get back home I will followup with a minimal reproduction
from node-ldapjs.
In WSL I tried adding a few console logs since debugging with breakpoints didn't really work when invoking ldapadd. Then I noticed the req.dn
param in server.add()
is empty for me with both the minimal example and the /etc/passwd server example.
const ldap = require('ldapjs');
const server = ldap.createServer();
server.bind('cn=root', (req, res, next) => {
res.end();
return next();
});
server.add('ou=users, o=myhost', [], (req, res, next) => {
console.log(req.dn); // this is an empty object for me
res.end();
return next();
});
server.listen(1389, '127.0.0.1', () => {
console.log('example LDAP server up at: %s', server.url);
});
Is there something wrong with my setup, or did I remove too much code?
I have added my install and test script to the example repository, it only uses a user.ldif
and no passwd
file. https://github.com/Ketho/ldapjs_example
from node-ldapjs.
- the string representation of
req.dn
iscn=ldapjs,ou=users,o=myhost
. req.dn.rdns
is undefined for me so it can't index it. I normally would've expected a js error message to show up.
server.add('ou=users, o=myhost', [], (req, res, next) => {
console.log("server.add.1", req.dn.toString(), req.dn.rdns);
if (!req.dn.rdns[0].cn)
return next(new ldap.ConstraintViolationError('cn required'));
console.log("server.add.2");
res.end();
return next();
});
Hope you can see if I'm doing something wrong here.
// console.log(req);
AddRequest [LdapMessage] {
log: { child: [Function (anonymous)] },
connection: <ref *1> Socket {
connecting: false,
_hadError: false,
_parent: null,
_host: null,
_closeAfterHandlingError: false,
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: [],
flowing: true,
ended: false,
endEmitted: false,
reading: false,
constructed: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
errorEmitted: false,
emitClose: false,
autoDestroy: true,
destroyed: false,
errored: null,
closed: false,
closeEmitted: false,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
dataEmitted: true,
decoder: null,
encoding: null,
[Symbol(kPaused)]: false
},
_events: [Object: null prototype] {
end: [Array],
timeout: [Function (anonymous)],
error: [Function (anonymous)],
close: [Function (anonymous)],
data: [Function (anonymous)]
},
_eventsCount: 5,
_maxListeners: undefined,
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 0,
constructed: true,
prefinished: false,
errorEmitted: false,
emitClose: false,
autoDestroy: true,
errored: null,
closed: false,
closeEmitted: false,
[Symbol(kOnFinished)]: []
},
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: Server {
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
_connections: 1,
_handle: [TCP],
_usingWorkers: false,
_workers: [],
_unref: false,
allowHalfOpen: false,
pauseOnConnect: false,
noDelay: false,
keepAlive: false,
keepAliveInitialDelay: 0,
highWaterMark: 16384,
log: [Object],
ldap: [Object],
_connectionKey: '4:127.0.0.1:1389',
[Symbol(kCapture)]: false,
[Symbol(async_id_symbol)]: 6
},
_server: Server {
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
_connections: 1,
_handle: [TCP],
_usingWorkers: false,
_workers: [],
_unref: false,
allowHalfOpen: false,
pauseOnConnect: false,
noDelay: false,
keepAlive: false,
keepAliveInitialDelay: 0,
highWaterMark: 16384,
log: [Object],
ldap: [Object],
_connectionKey: '4:127.0.0.1:1389',
[Symbol(kCapture)]: false,
[Symbol(async_id_symbol)]: 6
},
_peername: { address: '127.0.0.1', family: 'IPv4', port: 44352 },
ldap: {
id: '127.0.0.1:44352',
config: [Object],
_bindDN: DN [LdapDn] {},
bindDN: [Getter/Setter]
},
parser: Parser {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
buffer: null,
log: [Object],
[Symbol(kCapture)]: false
},
[Symbol(async_id_symbol)]: 10,
[Symbol(kHandle)]: TCP {
reading: true,
onconnection: null,
[Symbol(owner_symbol)]: [Circular *1]
},
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kSetNoDelay)]: false,
[Symbol(kSetKeepAlive)]: false,
[Symbol(kSetKeepAliveInitialDelay)]: 0,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0
},
logId: '127.0.0.1:44352::2',
startTime: 1694609333546,
suffix: DN [LdapDn] {}
}
from node-ldapjs.
Hi @Ketho - did you ever find the source of the issue of your "Operations Error'? I'm now getting the same issue when attempting to add an attribute on a MS Windows/LDAP server. When I perform the same operation on an Samba LDAP server no such error exists. Let me know - thanks.
from node-ldapjs.
I did not find the source of the error but your issue does sound like it would warrant making a separate ticket. In the end I resorted to testing with python ldap3 to learn about LDAP.
from node-ldapjs.
In case it might help someone - I did end up solving the issue! And this is important. For AD Windows servers, making any changes to schema using LDAP require the following conditions to be met:
- Whenever and wherever possible, make sure to make the changes on the server which is FSMO schema master holder.
- Make sure you are binding with credentials that have sufficient privileges to make changes to schema
- IMPORTANT: Make sure server replication is working and is reporting no errors. Test using
repadmin /showrepl
command.
I kept getting Operations Error message until I fixed replication on my server and once I ran the command above with no errors, POOF! like magic the LDAP operations I was sending (unchanged) worked perfectly. Too bad the error messages returned by LDAPjs don't report this correctly but that was the source of my issues. Hope that helps someone.
from node-ldapjs.
Related Issues (20)
- replace operation --> modification must be an Attribute HOT 1
- ldapmodify works, but ldapjs client.modify() does't work as expected and return No Such Object HOT 5
- Unable to use attributes: 'member;range=0-1499' in ldapjs search HOT 3
- Support for SyncRequestControl HOT 1
- Not able to set password after user created HOT 3
- LDAP search return empty array for every subsequent search after the first search. HOT 1
- VError: Parser error for undefined:undefined: options.value must be a Buffer or Object HOT 18
- Support unicode DN HOT 8
- How can I obtain information indicating "Password Expired"? HOT 1
- Obtaining search entry attribute value by key HOT 1
- Invalidate Error
- Whitespace in (old) parseFilter causes `Uncaught Error: missing paren`
- Module build failed: UnhandledSchemeError: Reading from "node:util" is not handled by plugins (Unhandled scheme). HOT 4
- SASL / GSSAPI support HOT 3
- Open ssl issue with node 18 HOT 1
- Compatibility Issue Between ldapjs Library and FreeRADIUS HOT 1
- Edited: Ldapjs doesn't work after next.js build HOT 5
- Sharing unescape DN code for helper method
- (node:536) [LDAP_MESSAGE_DEP_001] LdapjsMessageWarning: messageID is deprecated. Use messageId instead. HOT 1
- Missing LDAP Result Codes in errors.js HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-ldapjs.