37 lines
846 B
JavaScript
37 lines
846 B
JavaScript
var ldap = require('ldapjs');
|
|
|
|
module.exports = {
|
|
load: load,
|
|
setup: setup
|
|
};
|
|
|
|
function load(tcrud) {
|
|
var client = ldap.createClient({
|
|
url: 'ldap://127.0.0.1:389'
|
|
});
|
|
client.bind('cn=admin,dc=test,dc=net', 'test', function(err) {
|
|
if (err) {
|
|
console.log('bind eror: '+err);
|
|
} else {
|
|
console.log('bind oke');
|
|
}
|
|
});
|
|
|
|
// Create backend with id and uri
|
|
tcrud.backend.ldapjs.registrate('ldapjs/main',client);
|
|
}
|
|
|
|
function setup(tcrud,tcrudModel) {
|
|
// Create tcrud models
|
|
var tc = tcrud.config;
|
|
var t = tc.createTEntityNode(tcrudModel,'ldapjs');
|
|
t.tmeta.tmodel.tbackend = 'ldapjs/main';
|
|
|
|
// Define model and columns
|
|
var tUser = tc.createTEntity(t,'test_users','cn');
|
|
|
|
var tUserId = tc.createTField(tUser,'uid');
|
|
var tUserName = tc.createTField(tUser,'sn');
|
|
var tUserEmail = tc.createTField(tUser,'email');
|
|
}
|