2
0
Fork 0

Last open WIP commit to see ldap action.

This commit is contained in:
Willem Cazander 2020-12-01 14:23:29 +01:00
parent 3f929f9607
commit 4c72e7a5f8
7 changed files with 923 additions and 654 deletions

View file

@ -1,9 +1,9 @@
var config = require('./../tcrud-config');
var tcrudSetup = require('./../tcrud-setup');
var debug = require('debug')('ff:tcrud:ldapjs');
module.exports = {
registrate: function(key,client) {
config.registratePlugin(new LdapJSPlugin(key,client));
tcrudSetup.pluginLoad(new LdapJSPlugin(key,client));
}
}
@ -33,15 +33,18 @@ LdapJSBackend.prototype.getKey = function() {
return this.plugin.key;
}
// see http://ldapjs.org/client.html#connection-management
LdapJSBackend.prototype.findAll = function(tview,crudType) {
var self = this;
return function(data, dataParam, cb) {
var opts = {
filter: '(&(l=Seattle)(email=*@foo.com))',
filter2: '(&(l=Seattle)(email=*@foo.com))',
scope: 'sub'
};
debug('findAll %s',opts);
self.plugin.client.search('o=example', opts, function(err, res) {
var ss = 'ou=users,dc=nss,dc=forwardfire,dc=net';
console.log("ldap search "+ss);
self.plugin.client.search(ss, opts, function(err, res) {
if (err) {
debug(err);
cb(err);
@ -50,9 +53,12 @@ LdapJSBackend.prototype.findAll = function(tview,crudType) {
//var querySql = 'SELECT '+selectField(tview,crudType)+' FROM '+tview.tmeta.tmodel.tid+'';
var result = [];
res.on('searchEntry', function(entry) {
result.push(entry);
result.push(entry.object);
});
res.on('end', function(result) {
res.on('error', function(err) {
cb(err);
});
res.on('end', function(status) {
cb(err,result);
});
});