|
|
@ -55,16 +55,22 @@ def main(): |
|
|
|
lp = samba.param.LoadParm() |
|
|
|
lp.load(samba.param.default_path()) # или lp.load("/etc/samba/smb.conf") |
|
|
|
sam = SamDB(lp=lp, session_info=system_session()) |
|
|
|
expression = "(&(objectCategory=person)(objectClass=user))" |
|
|
|
|
|
|
|
res = sam.search(base=base, expression=expression, attrs=['*', 'userAccountControl']) |
|
|
|
for i in res: |
|
|
|
print(str(i['samAccountName'])) |
|
|
|
res, err = z_reader.mysql_reader(dbconn, sql) |
|
|
|
print(res) |
|
|
|
if err: |
|
|
|
print(err) |
|
|
|
exit(0) |
|
|
|
z_users = z_reader.users_make_zayavka(res) |
|
|
|
i = 0 |
|
|
|
for z_user in z_users: |
|
|
|
print(z_user, z_users[z_user]) |
|
|
|
ad_user = UserAd(sam, base, domainName, z_users[z_user]['samAccountName'], z_users[z_user]['usrPass']) |
|
|
|
if z_users[z_user]['toRemove']: # удаляем, если такой есть |
|
|
|
print("removing user") |
|
|
|
if ad_user.exists: |
|
|
|
ad_user.remove() |
|
|
|
dat, err = z_reader.mysql_reader(dbconn, sql_delete % z_users[z_user]['id']) |
|
|
@ -72,9 +78,14 @@ def main(): |
|
|
|
print(err) |
|
|
|
continue |
|
|
|
if not ad_user.exists: |
|
|
|
ad_user.add() |
|
|
|
print("make new user") |
|
|
|
ad_res = ad_user.add() |
|
|
|
if ad_res: |
|
|
|
print(ad_res) |
|
|
|
if z_users[z_user]['pwChange']: # обновляем пароль |
|
|
|
ad_user.set_passwd() |
|
|
|
ad_res = ad_user.set_passwd() |
|
|
|
if ad_res: |
|
|
|
print(ad_res) |
|
|
|
dat, err = z_reader.mysql_reader(dbconn, sql_update_changes % z_users[z_user]['id']) |
|
|
|
if err: |
|
|
|
print(err) |
|
|
|