我正在使用 python 的 ldap 模块 连接到 ldap 服务器.我可以查询数据库,但我不知道如何检索数据库中存在的字段,以便我可以提前通知用户查询数据库,告诉他试图访问的字段不在数据库中.
I am using ldap module of python to connect to ldap server. I am able to query the database but I dont know how to retrieve the fields present in the database, so that I can notify the user in advance to quering the database, telling him that the field he is trying to access is not in the database.
例如,如果存在的字段只是
For example if the fields present are just
cn
memberOf
如果用户尝试使用过滤器查询数据库
and if the user tries to query the database with filter
cn and memberOf and notcontained
我应该能够知道 notcontained 属性不在 dabase 架构中.
I should be able to know that the notcontained attribute is not in the dabase schema.
我怎样才能做到这一点.
How can I accomplish this.
谢谢.
我正在使用 python 的 ldap 模块连接到 ldap 服务器.我能查询数据库,但我不知道如何检索字段存在于数据库中,以便我可以提前通知用户查询数据库,告诉他他正在尝试的领域访问不在数据库中.
I am using ldap module of python to connect to ldap server. I am able to query the database but I dont know how to retrieve the fields present in the database, so that I can notify the user in advance to quering the database, telling him that the field he is trying to access is not in the database.
一个简单的解决方案是搜索然后从结果中打印一个键列表.
A simple solution would be to search and then print a list of the keys from the result.
import ldap
# connect to your ldap server
some_dn = '...' # Your base dn
some_lookup = '...' # your lookup attr
result = conn.search_s(some_dn,ldap.SCOPE_SUBTREE,some_lookup)
result[0][1].keys()
例如,针对我的 AD 服务器,它返回以下内容:
For example, against my AD server it returns the following:
['mailNickname',
'publicDelegatesBL',
'logonCount',
'cn',
'countryCode',
'dSCorePropagationData',
'objectClass',
# ... many many more
'telephoneNumber',
'physicalDeliveryOfficeName',
'name',
'memberOf',
'codePage',
'userAccountControl',
'msExchMDBRulesQuota',
'lastLogon',
'protocolSettings',
'uSNChanged',
'sn',
'msExchVersion',
'mDBUseDefaults',
'givenName',
'msExchMailboxGuid',
'lastLogoff']
这篇关于如何检索 LDAP 数据库的所有属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!