2017-06-10 14:53:29 +00:00
|
|
|
var ldap = require('ldapjs');
|
|
|
|
|
|
|
|
module.exports = {
|
2020-12-01 13:23:29 +00:00
|
|
|
load: load,
|
2017-06-10 14:53:29 +00:00
|
|
|
setup: setup
|
|
|
|
};
|
|
|
|
|
2020-12-01 13:23:29 +00:00
|
|
|
function load(tcrud) {
|
2017-06-10 14:53:29 +00:00
|
|
|
var client = ldap.createClient({
|
|
|
|
url: 'ldap://127.0.0.1:389'
|
|
|
|
});
|
2020-12-01 13:23:29 +00:00
|
|
|
client.bind('cn=admin,dc=test,dc=net', 'test', function(err) {
|
|
|
|
if (err) {
|
|
|
|
console.log('bind eror: '+err);
|
|
|
|
} else {
|
|
|
|
console.log('bind oke');
|
|
|
|
}
|
|
|
|
});
|
2017-06-10 14:53:29 +00:00
|
|
|
|
|
|
|
// Create backend with id and uri
|
2020-12-01 13:23:29 +00:00
|
|
|
tcrud.backend.ldapjs.registrate('ldapjs/main',client);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setup(tcrud,tcrudModel) {
|
2017-06-10 14:53:29 +00:00
|
|
|
// Create tcrud models
|
|
|
|
var tc = tcrud.config;
|
|
|
|
var t = tc.createTEntityNode(tcrudModel,'ldapjs');
|
|
|
|
t.tmeta.tmodel.tbackend = 'ldapjs/main';
|
|
|
|
|
|
|
|
// Define model and columns
|
2020-12-01 13:23:29 +00:00
|
|
|
var tUser = tc.createTEntity(t,'test_users','cn');
|
|
|
|
|
2017-06-10 14:53:29 +00:00
|
|
|
var tUserId = tc.createTField(tUser,'uid');
|
|
|
|
var tUserName = tc.createTField(tUser,'sn');
|
|
|
|
var tUserEmail = tc.createTField(tUser,'email');
|
|
|
|
}
|