unboundid ldap SDK如何获取所有用户并排除一个部门

unboundid ldap SDK how to get all users and exclude a department

我有示例代码

Filter searchFilter = Filter.create("(sAMAccountType=805306368)");
                        SearchRequest searchRequest =
                                new SearchRequest(advanceBaseDnTxt.getText(), SearchScope.SUB, searchFilter,
                                        ldapAttributeSet);
                        SearchResult searchResult = lcon.search(searchRequest);

这足以检索所有用户以及如何排除部门吗?

要取消 LDAP 过滤器上的属性,请查看此页面:http://www.ldapexplorer.com/en/manual/109010000-ldap-filter-syntax.htm

(!(department=<NUMBER TO EXCLUDE>))应该用

如果您需要过滤多个属性,从您的示例中您需要每个条目具有 sAMAccountType=805306368 而不在 department=<NUMBER TO EXCLUDE> 中,因此过滤器将是:

(&(sAMAccountType=805306368)(!(department=<NUMBER TO EXCLUDE>)))