在我的项目中,我使用 unboundid-ldapsdk 4.0.14 从活动目录获取更改通知。当在 AD 中更改对象时,我正在设置我需要的一堆属性。我面临的问题是我没有从 AD 的搜索结果中获得一些属性,例如 - uSNCreated、uSNChanged、userAccountControl、whenChanged。我的代码有什么问题吗?或者我必须在我的代码中包含一些东西来获取这些属性。
以下是代码:-
AsyncSearchResultListener listener = new AsyncSearchResultListener() {
@Override
public void searchReferenceReturned(SearchResultReference searchRef) {
if (searchRef != null) {
mLogger.info("searchReferenceReturned -> SearchResultReference: " + searchRef.toString());
}
}
@Override
public void searchEntryReturned(SearchResultEntry searchEntry) {
if (searchEntry != null) {
mLogger.info("----------RECEIVED STRAT-----------");
mLogger.info("Search entry: " + searchEntry);
}
}
@Override
public void searchResultReceived(AsyncRequestID requestID, SearchResult searchResult) {
}
};
SearchRequest searchRequest = new SearchRequest(listener, domainNamingContext, SearchScope.SUB,
"(objectClass=*)", "distinguishedName", "uSNChanged", "objectCategory", "isDeleted",
"msds-memberOfTransitive", "accountExpires", "badPasswordTime", "badPwdCount", "cn", "lDAPDisplayName",
"lastLogonTimestamp", "logonHours", "nTSecurityDescriptor", "objectClass", "objectGUID", "objectSid",
"primaryGroupID", "pwdLastSet", "sAMAccountName", "sAMAccountType", "userAccountControl",
"userPrincipalName", "uSNChanged", "usnCreated", "whenChanged", "whenCreated", "adminCount");
Control myControl = new Control("1.2.840.113556.1.4.528", true);
searchRequest.addControl(myControl);
Control myControl1 = new Control("1.2.840.113556.1.4.417", true);
searchRequest.addControl(myControl1);
Control myControl2 = new Control("1.2.840.113556.1.4.801", true, new ASN1OctetString(new ASN1Sequence(new ASN1Integer(7)).encode()));
searchRequest.addControl(myControl2);
connection.asyncSearch(searchRequest);