我有一些c代碼根據用戶cn爲用戶DN查詢openldap服務器,如下所示。當我使用Apache DS搜索ldap服務器時,僅顯示結果。我的C代碼返回2條記錄;一個與預期的用戶DN一樣,另一個記錄與空白DN!這是第二個記錄是什麼?這是預期的行爲?ldap_search_ext返回額外結果
爲了清晰起見,我已經包含下面的代碼示例,並刪除了所有錯誤檢查。
ldap_search_ext(ld, (char *)baseDN, LDAP_SCOPE_SUBTREE, "(&(objectClass=person)(cn=test00002))", NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &msgid);
ldap_result(ld, msgid, 1, NULL, &res);
numUsersFound = ldap_count_messages(ld, res);
syslog(LOG_DEBUG, "DEBUG Number of users found: (%d)", numUsersFound);
結果
DEBUG Number of users found: 2
DEBUG User DN: (cn=test00002,ou=defaultRealm,dc=company,dc=com)
DEBUG User DN:()