如何在 python-ldap 中根据其 dn 在 LDAP 中搜索对象? [英] How do I search for an object in LDAP based on its dn, in python-ldap?
本文介绍了如何在 python-ldap 中根据其 dn 在 LDAP 中搜索对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用例如search_s
函数根据其完整的可分辨名称搜索对象,但我发现这并不方便.例如,
I am trying to use e.g. the search_s
function to search for an object based on its full distinguished name, but am not finding this to be convenient. For example,
search_s('DC=example, DC=com', ldap.SCOPE_SUBTREE,
'(CN=Somebody, OU=Department, DC=example, DC=com)')
如何仅根据其完整的 LDAP 专有名称检索一个对象?
How do I just retrieve one object based on its full LDAP distinguished name?
推荐答案
使用 SCOPE_BASE
和通配符过滤器仅返回第一个参数给出的 dn(过滤器仍然必须匹配该对象!) 例如,
Use SCOPE_BASE
and a wildcard filter to return only the dn given by the first argument (the filter still has to match that object!) For example,
import ldap
...
ldap_connection.search_s('CN=Somebody, OU=Department, DC=example, DC=com',
ldap.SCOPE_BASE,
'(objectClass=*)')
这篇关于如何在 python-ldap 中根据其 dn 在 LDAP 中搜索对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文