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

Last change on this file since 1330 was 1330, checked in by kbut, 4 years ago

add script to sync users on install

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