Browse Source

добавил груп-сеты.

master
Mikhail Grebenkin 6 years ago
parent
commit
1cca47b3f9
1 changed files with 24 additions and 13 deletions
  1. +24
    -13
      zayavka_reader.py

+ 24
- 13
zayavka_reader.py View File

@ -10,7 +10,9 @@ dbconn = {'host': '10.1.11.26',
sql = 'select * from LDAP'
ad_groups = ['vpn-users', 'gogs']
ad_groups_users = ['vpn-users', 'gogs']
ad_groups_bitrix = ['vpn-web-vpn', 'gogs']
ad_groups_1c = ['vpn-1c-vpn']
def mysql_reader(dbconn, sql):
@ -33,27 +35,36 @@ def mysql_reader(dbconn, sql):
return data, err
def users_make_zayavka(users, memberOf):
def users_make_zayavka(users):
res = {}
for i in users:
usrName = str(i['LoginEmail']).split('@')[0]
usrname = str(i['LoginEmail']).split('@')[0]
enabled = False
pwChange = False
toRemove = False
pwchange = False
toremove = False
# преобразуем флаги в удобную форму
if i['Activ'] == 'Y':
enabled = True
if i['Changes'] == 'Y':
pwChange = True
pwchange = True
if i['Delete'] == 'Y':
toRemove = True
res[usrName] = {'id': str(i['ID']),
'samAccountName': usrName,
'memberOf': memberOf,
toremove = True
# размечаем группы, в которых должен быть пользователь
if str(i['Otdel']) == 'Users':
memberof = ad_groups_users
elif str(i['Otdel']) == '1c':
memberof = ad_groups_1c
elif str(i['Otdel']) == 'Bitrix':
memberof = ad_groups_bitrix
# собственно добавляем в мапу
res[usrname] = {'id': str(i['ID']),
'samAccountName': usrname,
'memberOf': memberof,
'usrPass': str(i['Pass']),
'groupSet': str(i['Otdel']),
'enabled': enabled,
'pwChange': pwChange,
'toRemove': toRemove
'pwChange': pwchange,
'toRemove': toremove
}
return res
@ -61,7 +72,7 @@ def users_make_zayavka(users, memberOf):
def main():
data, err = mysql_reader(dbconn, sql)
if not err:
users = users_make_zayavka(data, ad_groups)
users = users_make_zayavka(data)
for user in users:
print user, users[user]
else:


Loading…
Cancel
Save

Powered by TurnKey Linux.