node-ldap2json
Advanced tools
Comparing version 0.0.11 to 0.0.12
var | ||
extend = require('util')._extend, | ||
ldap = require('ldapjs') | ||
ldap = require('ldapjs'); | ||
var searchParts=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','r','s','t','u','v','y','z']; | ||
var | ||
pagedsearch = new ldap.PagedResultsControl({value:{size:500}}); | ||
additionalfilter = "(userAccountControl\:1.2.840.113556.1.4.803\:\=512)"; | ||
console.log("obje : "+JSON.stringify(pagedsearch)); | ||
var searchParts=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o', | ||
'p','r','s','t','u','v','y','z']; | ||
function lditem2obj(lditem){ | ||
@@ -30,20 +40,5 @@ var o= new Object(); | ||
function clientSearch(client,options,opts,cb){ | ||
//console.log('base:'+base+'\nopts:'+JSON.stringify(opts)); | ||
var items=[]; | ||
client.search(options.base,opts,function(err,res){ | ||
if (err) { | ||
console.log("clientSearchParamErr:"+err.message); | ||
cb(e.message,null); | ||
return; | ||
} | ||
res.on('searchEntry', function(entry) { | ||
items.push(entry.object); | ||
}); | ||
res.on('error', function(err2) { | ||
if (err2.message!='Size Limit Exceeded') { | ||
console.log("\033[41m\033[33mclientSearch:"+err2.message+"("+options.base+")\033[0m"); | ||
cb(err2,null); | ||
} else { | ||
items=[]; | ||
function partedSearch(client,options,opts,cb){ | ||
items=[]; | ||
var newopts=extend({},opts); | ||
@@ -62,3 +57,3 @@ var working=searchParts.length; | ||
working--; | ||
if (working<=0){ | ||
if (working<=0){ //All parts finished, now searching others | ||
var sonClient=ldap.createClient({url:client.url.href}); | ||
@@ -100,6 +95,28 @@ sonClient.bind(options.adminuser,options.adminpass,function(e){ | ||
}); | ||
} | ||
function clientSearch(client,options,opts,cb){ | ||
var items=[]; | ||
if (opts.filter.indexOf(additionalfilter)<0){ | ||
opts.filter='(&'+opts.filter+additionalfilter+')'; | ||
} | ||
opts.filter='(&'+opts.filter+additionalfilter+')'; | ||
client.search(options.base,opts,[pagedsearch],function(err,res){ | ||
if (err) { | ||
console.log("clientSearchParamErr:"+err.message); | ||
cb(e.message,null); | ||
return; | ||
} | ||
res.on('searchEntry', function(entry) { | ||
items.push(entry.object); | ||
}); | ||
res.on('error', function(err2) { | ||
if (err2.message!='Size Limit Exceeded') { | ||
console.log("\033[41m\033[33mclientSearch:"+err2.message+"("+options.base+")\033[0m"); | ||
cb(err2,null); | ||
} else { | ||
console.log("Size Limit Geçildi......."); | ||
} | ||
return; | ||
//cb(err2.message,null); | ||
//return; | ||
}); | ||
@@ -130,3 +147,3 @@ res.on('end', function(result) { | ||
scope: 'sub', | ||
filter: '(&(objectClass='+objecttype+')(cn=*'+keyword+'*))' | ||
filter: '(&(objectClass='+objecttype+')(cn=*'+keyword+'*)'+additionalfilter+')' | ||
}; | ||
@@ -142,3 +159,3 @@ | ||
client.search(options.base,opts,function(err,res){ | ||
client.search(options.base,opts,[pagedsearch],function(err,res){ | ||
if (err) { | ||
@@ -145,0 +162,0 @@ console.log("search:ClientSearchParamErr:"+err.message); |
{ | ||
"name": "node-ldap2json", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "LDAP2JSON makes shortcuts LDAP.JS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -27,3 +27,3 @@ var | ||
it('returns a user',function(done){ | ||
ldap2json.checkUser(testVariables.TreeOptions,'serkan','1',function(e,usr){ | ||
ldap2json.checkUser(testVariables.TreeOptions,testVariables.testuser,testVariables.testuserpass,function(e,usr){ | ||
usr.should.be.object; | ||
@@ -30,0 +30,0 @@ done(); |
172493
437