Удалён тест и файл
parent
5813e93ddc
commit
94a43a061f
|
@ -1,52 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
from ldap3 import Server, Connection, ALL, NTLM, SUBTREE, SAFE_SYNC, BASE
|
||||
# from samba.samdb import SamDB
|
||||
# from samba.auth import system_session
|
||||
# from samba.ndr import ndr_pack, ndr_unpack
|
||||
# from samba.dcerpc import security
|
||||
# import samba.param
|
||||
import logging
|
||||
from pprint import pprint
|
||||
import json
|
||||
import csv
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
|
||||
|
||||
class AD_provaider():
|
||||
def __init__(self, url:str, serch_tree:str, user, password) -> None:
|
||||
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s")
|
||||
self.__server = Server(url)
|
||||
self.__connect = Connection(self.__server, user, password)
|
||||
self.__ad_serch_tree = serch_tree
|
||||
if self.__connect.bind():
|
||||
logging.info("status connect AD.........ok")
|
||||
else:
|
||||
logging.warning("status connect AD.........error")
|
||||
|
||||
|
||||
|
||||
def search_ms_ad(self, search_filter ,filter:list = ["*"])->dict:
|
||||
logging.info("search >>>>>>>>>>>>>> AD")
|
||||
self.__connect.search(self.__ad_serch_tree, search_filter, SUBTREE, attributes=filter)
|
||||
response = self.__connect.response_to_json()
|
||||
response = json.loads(response)
|
||||
response = json.dumps(response, ensure_ascii="utf-8")
|
||||
out = json.loads(response)
|
||||
pprint(out, indent=4)
|
||||
# return json.loads(response)
|
||||
|
||||
|
||||
MS_AD_ADRESS = 'ldap://cp-vm-dc01.energo.ru'
|
||||
SEARCH_FREE_MS = "dc=energo,dc=ru"
|
||||
MS_USER = 'energo\\administrator'
|
||||
PASSWORD = "P@sww0rd"
|
||||
PATH_SCV = "List_groups.csv"
|
||||
|
||||
SEARCH_FREE_SAMBA = "dc=lenenergo,dc=ru"
|
||||
|
||||
ad = AD_provaider(MS_AD_ADRESS, SEARCH_FREE_MS, MS_USER, PASSWORD)
|
||||
|
||||
# ad.search_ms_ad("(&(objectCategory=group)(name=test)(distinguishedName=CN=test,ou,base))") # Поиск
|
||||
|
Loading…
Reference in New Issue