source: lliurex-moodle/trunk/fuentes/lliurex-moodle.install-files/usr/share/lliurex-moodle/sync_ldap_users.py @ 1343

Last change on this file since 1343 was 1343, checked in by jrpelegrina, 4 years ago

Fix sync ldap users script

File size: 873 bytes
Line 
1#!/usr/bin/env python
2import xmlrpclib as x
3c = x.ServerProxy('https://localhost:9779')
4returncode = 0
5try:
6        magickey = open('/etc/n4d/key').readlines()[0].strip()
7        returncode = 1
8except Exception as e:
9        pass
10
11if returncode == 1:
12        try:
13                groupstosync = c.get_available_groups(magickey,'Golem')
14
15                environment = {'NEVERLAND_VAR':'add_user','ARGV':{}}
16                execfile('/usr/share/n4d/hooks/golem/51_moodle_create-cohorte.py',environment)
17
18                for group in groupstosync:
19                        environment = {'NEVERLAND_VAR':'add_group','ARGV':{'group':{'cn':group['cn'][0]}}}
20                        execfile('/usr/share/n4d/hooks/golem/51_moodle_create-cohorte.py',environment)
21                        for user in group['memberUid']:
22                                environment = {"NEVERLAND_VAR":"add_to_group","ARGV":{"group":{"cn":group["cn"][0]},"user":{"uid":user}}}
23                                execfile('/usr/share/n4d/hooks/golem/51_moodle_create-cohorte.py',environment)
24        except:
25                pass
Note: See TracBrowser for help on using the repository browser.