OK, now I get the BindResponse printed to console server side, but then I get:
W20181207-16:21:21.565(1)? (STDERR) (node:28726) UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded
W20181207-16:21:21.565(1)? (STDERR) at Object.keys.forEach.key (packages/ejson/ejson.js:594:27)
W20181207-16:21:21.565(1)? (STDERR) at Array.forEach (<anonymous>)
W20181207-16:21:21.565(1)? (STDERR) at Object.EJSON.clone.v [as clone] (packages/ejson/ejson.js:594:18)
W20181207-16:21:21.565(1)? (STDERR) at Object.keys.forEach.key (packages/ejson/ejson.js:595:22)
W20181207-16:21:21.566(1)? (STDERR) at Array.forEach (<anonymous>)
W20181207-16:21:21.566(1)? (STDERR) at Object.EJSON.clone.v [as clone] (packages/ejson/ejson.js:594:18)
W20181207-16:21:21.566(1)? (STDERR) at Object.keys.forEach.key (packages/ejson/ejson.js:595:22)
W20181207-16:21:21.566(1)? (STDERR) at Array.forEach (<anonymous>)
W20181207-16:21:21.566(1)? (STDERR) at Object.EJSON.clone.v [as clone] (packages/ejson/ejson.js:594:18)
W20181207-16:21:21.566(1)? (STDERR) at Object.keys.forEach.key (packages/ejson/ejson.js:595:22)
W20181207-16:21:21.566(1)? (STDERR) at Array.forEach (<anonymous>)
W20181207-16:21:21.566(1)? (STDERR) at Object.EJSON.clone.v [as clone] (packages/ejson/ejson.js:594:18)
W20181207-16:21:21.567(1)? (STDERR) at Object.keys.forEach.key (packages/ejson/ejson.js:595:22)
W20181207-16:21:21.567(1)? (STDERR) at Array.forEach (<anonymous>)
W20181207-16:21:21.567(1)? (STDERR) at Object.EJSON.clone.v [as clone] (packages/ejson/ejson.js:594:18)
W20181207-16:21:21.567(1)? (STDERR) at Object.keys.forEach.key (packages/ejson/ejson.js:595:22)
W20181207-16:21:21.567(1)? (STDERR) (node:28726) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)
Client:
handleSubmit(event) {
const that = this;
event.preventDefault();
const email = document.getElementById('login-email').value;
const password = document.getElementById('login-password').value;
Meteor.call(
'ldap.authenticate',
'<url>',
'<dn>',
email,
password,
(err, res) => {
if (err) {
that.setState({ error: err });
that.setState({ authenticated: false });
throw new Error('ldap.authenticate failed');
}
console.log('ldap.authenticate', res);
that.setState({ authenticated: true });
},
);
}
Server:
if (Meteor.isServer) {
Meteor.methods({
/**
* LDAP authentication method.
*
* @param {String} url LDAP server url.
* @param {String} dn distinguished name.
* @param {String} email LDAP binddn.
* @param {String} password LDAP password.
*/
'ldap.authenticate': (url, dn, email, password) => {
const client = ldap.createClient({ url });
const clientBind = Meteor.wrapAsync(client.bind, client);
try {
const res = clientBind(email, password);
console.log(res);
return res;
} catch (err) {
throw new Meteor.Error('xxx', 'yyy');
}
},
});
}