16 Star 44 Fork 45

现任明教教主-乾颐堂 / 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'))
Python
1
https://gitee.com/qytang/qytang_Python.git
git@gitee.com:qytang/qytang_Python.git
qytang
qytang_Python
qytang_Python
master

搜索帮助