2
0
Fork 0
tcrud/example/lib/ldapjs-example.js

37 lines
846 B
JavaScript
Raw Normal View History

2017-06-10 14:53:29 +00:00
var ldap = require('ldapjs');
module.exports = {
load: load,
2017-06-10 14:53:29 +00:00
setup: setup
};
function load(tcrud) {
2017-06-10 14:53:29 +00:00
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');
}
});
2017-06-10 14:53:29 +00:00
// Create backend with id and uri
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
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');
}