0

I tried to query 'LDAP server users' with my node.js server. here is my codes what i tried with 'Ldapjs framework'

function ldapQuery_Users(){
var opts = {
    filter: '(uid=*)',
    scope: 'sub'
// attributes: ['dn', 'sn', 'cn', 'phone', 'fax', 'mail']
};

client.search('dc=mirageworks, dc=kr', opts, function(err, res) {
    assert.ifError(err);
    res.on('searchEntry', function(entry) {
      console.log(entry.attributes.toString());
    });
    res.on('searchReference', function(referral) {
      console.log('referral: ' + referral.uris.join());
    });
    res.on('error', function(err) {
      console.error('error: ' + err.message);
    });
    res.on('end', function(result) {
      //console.log('ldapLogin status: ' + ((result.status == 0) ? "success" :  result.status));
    });
 });
}

And the result is like this.

enter image description here

When I set attributes items in opts array, the results are sorted as what I set. But with no attributes, no sorted items.

The first user's result is starting "type" : "uid". these items seem ascending sorted. But second and thrid are decending sorted. these are starting with "type":"telephoneNumber"

4

1 回答 1

1

LDAP 协议特别声明结果顺序是未指定的。

LDAP 服务器实现可以按特定顺序返回条目或属性,但是没有标准。

使用LDAP 控制扩展对搜索结果进行服务器端排序可以按指定顺序返回条目。

没有用于对属性结果进行排序的“标准”,它们需要在“客户端”进行排序

于 2017-08-02T11:42:28.497 回答