-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
22 lines (19 loc) · 705 Bytes
/
Copy pathmain.py
File metadata and controls
22 lines (19 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import csv
import os
from pyad import *
from dotenv import load_dotenv
load_dotenv() # take environment variables from .env.
def createuserfromcsv():
#takes full file path
file = input('please type your file path + file: ')
data = open(file,encoding="utf-8")
csv_data = csv.reader(data)
data_lines = list(csv_data)
#load admin information
pyad.set_defaults(ldap_server="DC-01.l1-2.lab", username= os.getenv('USERNAME'), password= os.getenv('PASSWORD'))
for line in data_lines[1:]:
user = line[0]
oupath = line[2]
ou = pyad.adcontainer.ADContainer.from_dn(oupath)
pyad.aduser.ADUser.create(user,ou,password="abc-123")
createuserfromcsv()