0
「検索」メソッドを使用してldapjsを検索しようとしていますが、それは私のためには機能しません。ここでLdapjs検索が機能していません
は、端末からの応答である:成功し、新しいユーザーを追加しようとしました
const ldap = require('ldapjs');
const ldapOptions = {
url: 'ldaps://example.com',
port: '363'
};
const client_admin = ldap.createClient(ldapOptions);
let searchUser =() => {
client_admin
.bind('cn=admin,dc=example,dc=com', 'secret', (err) => {
if (err) return console.log('Error is', err);
});
let opts = {
filter: 'cn=admin'
}
client_admin.search('dc=example,dc=com', opts, (err, res) => {
res.on('searchEntry', (entry) => {
console.log('Entry', JSON.stringify(entry.object));
});
res.on('searchReference', (referral) => {
// console.log('Referral', referral);
});
res.on('error', (err) => {
// console.log('Error is', err);
});
res.on('end', (result) => {
console.log('Result is', result);
})
})
};
:ここ
> Result is: SearchResponse {
messageID: 2,
protocolOp: 101,
controls: [],
log:
Logger {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
_isSimpleChild: true,
_level: 30,
streams: [ [Object] ],
serializers:
{ req: [Function: req],
res: [Function: res],
err: [Function: err] },
src: false,
fields:
{ name: 'ldapjs',
component: 'client',
hostname: 'nichita-Lenovo-ideapad-500-15ISK',
pid: 29307,
clazz: 'Client' } },
status: 0,
matchedDN: '',
errorMessage: '',
referrals: [],
connection:
TLSSocket {
_tlsOptions:
{ pipe: undefined,
secureContext: [Object],
isServer: false,
requestCert: true,
rejectUnauthorized: true,
session: undefined,
NPNProtocols: undefined,
requestOCSP: undefined },
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: undefined,
authorized: true,
authorizationError: null,
encrypted: true,
_events:
{ finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
secure: [Function],
data: [Function: onData],
close: [Object],
end: [Function: onEnd],
error: [Function: onSocketError],
timeout: [Function: onTimeout] },
_eventsCount: 8,
_connecting: false,
_hadError: false,
_handle:
TLSWrap {
_externalStream: {},
fd: 13,
_parent: [Object],
_parentWrap: undefined,
_secureContext: [Object],
reading: true,
owner: [Circular],
onread: [Function: onread],
writeQueueSize: 1,
onhandshakestart: [Function],
onhandshakedone: [Function: bound ],
onocspresponse: [Function: bound onocspresponse],
onerror: [Function] },
_parent: null,
_host: 'ldap.titanium-soft.com',
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: false,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null,
resumeScheduled: false },
readable: true,
domain: null,
_maxListeners: undefined,
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false },
writable: true,
allowHalfOpen: false,
destroyed: false,
bytesRead: 28,
_bytesDispatched: 134,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
ssl:
TLSWrap {
_externalStream: {},
fd: 13,
_parent: [Object],
_parentWrap: undefined,
_secureContext: [Object],
reading: true,
owner: [Circular],
onread: [Function: onread],
writeQueueSize: 1,
onhandshakestart: [Function],
onhandshakedone: [Function: bound ],
onocspresponse: [Function: bound onocspresponse],
onerror: [Function] },
server: undefined,
_requestCert: true,
_rejectUnauthorized: true,
read: [Function],
_consuming: true },
attributes: [],
notAttributes: [],
sentEntries: 0 }
がコードです。しかし、私は何の反応もありませんでした。 この方法でデータを取得するにはどうすればよいですか?
だから、あなたがユーザーを検索または追加しているのですか?コードのどの部分が失敗していますか?期待される行動と実際の行動は? – Arg0n
私は探しています。 ldapに新しいユーザーを追加しようとしましたが、正常でした。 しかし、私が検索しようとすると、間違っている –