在 GCP 云功能中使用 nodejs 连接到 LDAP 时出现以下错误
错误:TypeError:Object.createClient 所需的选项(对象)
索引.js
exports.helloWorld = (event, context) => {
const gcsEvent = event;
var username = ***;
var password = ***;
console.log(`hello world`);
var ldap = require('ldapjs');
var client =ldap.createClient(username, password)({
url: 'LDAP://...'
})
client.bind(username, password, function(error){
if(error){
console.log("error");
}
else{
console.log("Connected to ldap");
}
})
}
包.json
{
"name": "sample-http",
"version": "0.0.1",
"author": "sang",
"description": "LDAP Binding for node.js",
"dependencies": {
"ldapjs": "^0.7.1"
}
}