Reputation: 11
I'm trying to do a webpage in React, I need to login against an existing Active Directory. I'm using ldapjs, (npm install ldapjs), the callback Login button is:
async login(){
console.log('Login');
var ldapjs = require('ldapjs')
return new Promise((resolve, reject) => {
const ldapClient = ldapjs.createClient({url: 'ldap://...'},
(err, res) => {
if (err) {
console.log("ERROR")
return reject(err);
}
console.log("OK")
return resolve(res);
})
})
}
I'm getting the following error:
TypeError: net.connect is not a functionclient.js:1035 Preact 2 connectSocket connect apply self-hosted:1868 Preact 2 emit onBackoff_ self-hosted:867
Upvotes: 1
Views: 8661
Reputation: 9073
Unfortunately, ldapjs is a server side module, designed to be used in NodeJS. You can't use it in the browser on the client side, only server side.
If you look at the official site here, you can see (above the code snippet) that it specifically says it's for use in Node.
Upvotes: 2