基于python的广告用户查询

2024-10-01 07:18:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图编写一个python脚本来验证某个特定域中是否存在用户名。在

To query :
           username -- > anandabhis
           domain name --> example.com
Output : Successfully verified .

为此,我使用PythonLDAP模块连接到ldap服务器。但是,即使在阅读了大量的文档之后,我也无法继续进行下去。在

^{pr2}$

Tags: 模块toname脚本comoutputexampledomain
1条回答
网友
1楼 · 发布于 2024-10-01 07:18:39

简单搜索用户的sAMAccountName,就可以获得用户的属性。在

user_filter = '(sAMAccountName={})'.format(search_username)
base_dn = 'DC={},DC=com'.format(domain)
result = connection.search_s(base_dn, ldap.SCOPE_SUBTREE, user_filter)
print result

相关问题 更多 >