python3使用ldap3对接AD域

ldap3官方文档:https://ldap3.readthedocs.io/en/latest/installation.html

项目代码


#!/usr/bin/env python
# coding: utf-8
#  安装
# pip install ldap3

from ldap3 import Server, Connection, ALL, NTLM,SAFE_SYNC

server = Server('fs86.abc.defs-ad', use_ssl=True,get_info=ALL) 
conn = Connection(server, user='CNVWFS02\dkx***', password="password", auto_bind=True)

conn.extend.standard.who_am_i()
result = conn.search(search_base='DC=fs86,DC=abc,DC=defs-ad', search_filter='(sAMAccountName=DKX***)', attributes= ['memberOf'])
res = conn.response
memberOf = res[0]['raw_attributes']['memberOf']
获取用户组信息

你可能感兴趣的:(ldap3对接AD,python对接,ad域对接,ldap3)