27 lines
663 B
JavaScript
27 lines
663 B
JavaScript
var ldap = require('ldapjs');
|
|
|
|
module.exports = {
|
|
setup: setup
|
|
};
|
|
|
|
function setup(tcrud,tcrudModel) {
|
|
|
|
var client = ldap.createClient({
|
|
url: 'ldap://127.0.0.1:389'
|
|
});
|
|
|
|
// Create backend with id and uri
|
|
tcrud.plugin.backend.ldapjs.registrate('ldapjs/main',client);
|
|
|
|
// 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,'cn=foo, o=example','cn');
|
|
var tUserId = tc.createTField(tUser,'uid');
|
|
var tUserName = tc.createTField(tUser,'sn');
|
|
var tUserEmail = tc.createTField(tUser,'email');
|
|
}
|