Changeset 1343


Ignore:
Timestamp:
May 2, 2016, 1:23:56 PM (3 years ago)
Author:
jrpelegrina
Message:

Fix sync ldap users script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lliurex-moodle/trunk/fuentes/lliurex-moodle.install-files/usr/share/lliurex-moodle/sync_ldap_users.py

    r1330 r1343  
    11#!/usr/bin/env python
    22import 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
    310
    4 c = x.ServerProxy('https://localhost:9779')
    5 try:
    6         magickey = open('/etc/n4d/key').readlines()[0]
    7 except Exception as e:
    8         return 0
     11if returncode == 1:
     12        try:
     13                groupstosync = c.get_available_groups(magickey,'Golem')
    914
    10 groupstosync = c.get_available_groups(magickey,'Golem')
     15                environment = {'NEVERLAND_VAR':'add_user','ARGV':{}}
     16                execfile('/usr/share/n4d/hooks/golem/51_moodle_create-cohorte.py',environment)
    1117
    12 'add_user'
    13 environment = {'NEVERLAND_VAR':'add_user','ARGV':{}}
    14 execfile('/usr/share/n4d/hooks/golem/51_moodle_create-cohorte.py',{})
    15 
    16 ['group']['cn']
    17 ['user']['uid']
    18 add_group
    19 add_to_group
    20 for 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 
     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 TracChangeset for help on using the changeset viewer.