如何使用 jndi 验证目录(LDAP 或 AD)中是否存在对象?
目前我们正在做类似的事情:
Attributes attributes = directoryConnection.find(filter, false);
if (attributes == null) {
// then the object does not exist
}
我认为这效率不高,我们不需要检索整个属性(在组对象的情况下它们可能是几千......我只是想知道该对象是否存在或不存在)
是否有更好的方法来检查对象是否存在?我可以使用对象的 cn 或它的整个 dn
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要确定“对象”是否存在,您必须搜索该对象。搜索请求至少包含:
加上一些其他可选参数,例如大小限制和时间限制等。搜索对象,请求属性
1.1
,搜索响应将指示返回了多少条目。如果返回的条目数为零,则该对象不存在。有关详细信息,请参阅“LDAP:ldapsearch”和"LDAP:编程实践”。To determine if an "object" exists, you must search for the object. A search request consists of at least:
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. If the number of entries returned is zero, then the object does not exist. For further information, see "LDAP: ldapsearch" and "LDAP: Programming Practices".