from ldap3 import Server, Connection, ALL, NTLM
import datetime
定义一个类用于操作AD
class operate_AD():
def init(self,Domain,User,Password):
self.domain=Domain
self.user=User
self.pwd=Password
self.DC=','.join(['DC=' + dc for dc in Domain.split('.')])
self.pre = Domain.split('.')[0].upper()
self.server = Server(self.domain, use_ssl=True,get_info=ALL)
self.conn = Connection(self.server, user=self.pre+'\'+self.user, password=self.pwd, auto_bind=True)
self.u_time=datetime.date.today()
def Get_All_UserInfo(self):
'''
查询组织下的用户
org: 组织,格式为:aaa.bbb 即bbb组织下的aaa组织,不包含域地址
'''
att_list = ['displayName', 'userPrincipalName','userAccountControl',