简体   繁体   English

如何使用jndi验证目录(LDAP或AD)中是否存在对象?

[英]How to verify if an object does exist in a directory (LDAP or AD) using jndi?

Currently we are doing something like: 目前,我们正在做类似的事情:

Attributes attributes = directoryConnection.find(filter, false);
if (attributes == null) {
    // then the object does not exist
}

i think this is not efficient, we don't need to retrieve the whole attributes (they could be a few thousends in the case of a group object... i just want to know if the object does exist or not) 我认为这样做效率不高,我们不需要检索整个属性(在使用组对象的情况下,它们可能会有几千个...我只是想知道对象是否存在)

is there a better way to check if the object does exist? 有没有更好的方法来检查对象是否存在? i can use the cn of the object or the whole dn of it 我可以使用对象的cn或整个dn

To determine if an "object" exists, you must search for the object. 要确定是否存在“对象”,必须搜索该对象。 A search request consists of at least: 搜索请求至少包含:

  • base object 基础对象
  • scope 范围
  • filter 过滤
  • requested attributes 要求的属性

Plus some other, optional, parameters such as size limit and time limit, and so forth. 加上一些其他可选参数,例如大小限制和时间限制,等等。 Search for the object, request attribute 1.1 , and the search response will have an indication of how many entries are returned. 搜索对象,请求属性1.1 ,搜索响应将指示返回了多少个条目。 If the number of entries returned is zero, then the object does not exist. 如果返回的条目数为零,则该对象不存在。 For further information, see "LDAP: ldapsearch" and "LDAP: Programming Practices" . 有关更多信息,请参见“ LDAP:ldapsearch”“ LDAP:编程实践”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM