2018-06-22 17:54:55 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import random
|
|
|
|
import subprocess
|
|
|
|
import string
|
|
|
|
|
|
|
|
from common import *
|
|
|
|
|
|
|
|
LDAP_BASE = "cn=users,dc=sawtooth,dc=claremontmakerspace,dc=org"
|
|
|
|
RAND_PW_LEN = 20
|
|
|
|
|
2018-07-20 11:45:45 -04:00
|
|
|
def makeSets(props):
|
|
|
|
return sum([["--set", key + "=" + value]
|
|
|
|
for key, value in props.items()], [])
|
|
|
|
|
2018-06-22 17:54:55 -04:00
|
|
|
def main():
|
|
|
|
members = getMembershipworksData("lvl,phn,eml,lbl,nam,end,_id")
|
|
|
|
|
|
|
|
for member in members:
|
|
|
|
randomPass = ''.join(random.choice(string.ascii_letters + string.digits)
|
|
|
|
for x in range(0, RAND_PW_LEN))
|
2018-07-20 11:45:45 -04:00
|
|
|
username = member["Account Name"].lower().replace(" ", ".")
|
|
|
|
|
2018-06-22 17:54:55 -04:00
|
|
|
props = {
|
2018-07-20 11:45:45 -04:00
|
|
|
"title": "", # Title
|
|
|
|
"firstname": member["First Name"],
|
|
|
|
"lastname": member["Last Name"], # (c)
|
|
|
|
"username": username, # (cmr)
|
|
|
|
"description": "", # Description
|
|
|
|
"password": randomPass, # (c) Password
|
|
|
|
#"mailPrimaryAddress": member["Email"], # Primary e-mail address
|
|
|
|
#"displayName": "", # Display name
|
|
|
|
#"birthday": "", # Birthdate
|
|
|
|
#"jpegPhoto": "", # Picture of the user (JPEG format)
|
2018-06-22 17:54:55 -04:00
|
|
|
|
2018-07-20 11:45:45 -04:00
|
|
|
"employeeNumber": member["Account ID"],
|
|
|
|
#"employeeType": "", # Employee type
|
2018-06-22 17:54:55 -04:00
|
|
|
|
2018-07-20 11:45:45 -04:00
|
|
|
#"groups": "", # Groups
|
2018-06-22 17:54:55 -04:00
|
|
|
|
2018-07-20 11:45:45 -04:00
|
|
|
"homedrive": "H:", # Windows home drive
|
|
|
|
"sambahome": "\\\\ucs\\" + username, # Windows home path
|
|
|
|
"profilepath": "%LOGONSERVER%\\%USERNAME%\\windows-profiles\\default", # Windows profile directory
|
2018-06-22 17:54:55 -04:00
|
|
|
|
2018-07-20 11:45:45 -04:00
|
|
|
"disabled": "1" if member["Account on Hold"] != "" else "0",
|
|
|
|
#"userexpiry": member["Renewal Date"],
|
2018-06-22 17:54:55 -04:00
|
|
|
|
2018-07-20 11:45:45 -04:00
|
|
|
"pwdChangeNextLogin": "1", # User has to change password on next login
|
2018-06-22 17:54:55 -04:00
|
|
|
|
2018-07-20 11:45:45 -04:00
|
|
|
#"sambaLogonHours": "", # Permitted times for Windows logins
|
2018-06-22 17:54:55 -04:00
|
|
|
|
2018-07-20 11:45:45 -04:00
|
|
|
"e-mail": member["Email"], # ([]) E-mail address
|
|
|
|
"phone": member["Phone"], # Telephone number
|
|
|
|
#"PasswordRecoveryMobile": member["Phone"], # Mobile phone number
|
|
|
|
"PasswordRecoveryEmail": member["Email"]
|
|
|
|
}
|
2018-06-22 17:54:55 -04:00
|
|
|
|
2018-07-20 11:45:45 -04:00
|
|
|
subprocess.call(["udm", "users/user", "create",
|
|
|
|
"--position", LDAP_BASE] + makeSets(props))
|
2018-06-22 17:54:55 -04:00
|
|
|
|
2018-07-20 11:45:45 -04:00
|
|
|
# remove props we don't want to reset
|
|
|
|
props.pop("password")
|
|
|
|
props.pop("pwdChangeNextLogin")
|
2018-06-22 17:54:55 -04:00
|
|
|
|
2018-07-20 11:45:45 -04:00
|
|
|
subprocess.call(["udm", "users/user", "modify",
|
|
|
|
"--dn", "uid=" + username + "," + LDAP_BASE]
|
|
|
|
+ makeSets(props))
|
2018-06-22 17:54:55 -04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|