1 Star 0 Fork 46

xiaozhu1215/qytang_Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
2016.02.20 查询AD域里边英文用户名所对应的中文名字 747 Bytes
一键复制 编辑 原始数据 按行查看 历史
现任明教教主-乾颐堂 提交于 2016-02-20 09:51 . new file
#!/usr/bin/python3.4
# -*- coding=utf-8 -*-
from ldap3 import Server, Connection, AUTO_BIND_NO_TLS, LEVEL, SUBTREE, BASE, ALL_ATTRIBUTES, ObjectDef, AttrDef, Reader, Entry, Attribute,OperationalAttribute
import ldap3
def findCNName(username):
server = Server('qytang.com')
c = Connection(server, auto_bind=AUTO_BIND_NO_TLS, user='qytang\xxxx', password='xxxx')
c.search(search_base = 'ou=CCIESECURITY, ou=Security, ou=QYT, dc=qytang, dc=com',
search_filter='(sAMAccountName=%s)' % username,
search_scope=LEVEL,
attributes = ALL_ATTRIBUTES,
paged_size = 100)
return c.response[0]['attributes']['displayName'][0]
if __name__ == '__main__':
print(findCNName('sec-zzy'))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/xiaozhu1215/qytang_Python.git
git@gitee.com:xiaozhu1215/qytang_Python.git
xiaozhu1215
qytang_Python
qytang_Python
master

搜索帮助