我一直在尝试转换以下 ldapsearch 查询
I've been trying to convert the following ldapsearch query
ldapsearch -H ldap://ldap.berkeley.edu -x -b 'ou=people,dc=berkeley,dc=edu' objectclass=*
到 ldapjs 脚本:
var ldap = require('ldapjs');
var server = 'ldap://ldap.berkeley.edu';
var searchBase = 'ou=people,dc=berkeley,dc=edu';
var client = ldap.createClient({
url: server
});
var opts = {
filter: '(objectclass=*)'
};
client.search(searchBase, opts, function(err, res) {
res.on('searchEntry', function (entry) {
console.log(entry.toString());
});
});
ldapsearch 给了我很多结果,但 ldapjs 没有返回任何用户.
您可以在 GitHub 上找到解决此问题的一些尝试.
The ldapsearch gives me plenty of results but ldapjs doesn't return any users.
You can find some attempts of solving this on GitHub.
ldapjs 搜索范围是从 UMich 代码派生的 OpenLDAP 和 (AFAIK) 最相似的 C 库的倒退".ldapjs 中的默认范围是base",而不是sub".在没有看到任何数据的情况下,您可能需要使该代码看起来像:
ldapjs search scopes are "backwards" of OpenLDAP and (AFAIK) most similar C libraries that are derived from the UMich code. The default scope in ldapjs is "base", as opposed to "sub". Without seeing any of your data, you probably need to make that code look like:
var opts = {
filter: '(objectclass=*)',
scope: 'sub'
};
client.search(searchBase, opts, function(err, res) {
res.on('searchEntry', function (entry) {
console.log(entry.toString());
});
});
这篇关于ldapsearch 到 ldapjs 的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!