Index: trunk/tools/subversion/user-management/add-labs-user |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | #!/usr/bin/python |
3 | | -import sys, subprocess, ldapsupportlib |
| 3 | +import sys, subprocess, ldapsupportlib, scriptconfig, mwclient |
4 | 4 | from optparse import OptionParser |
5 | 5 | |
6 | 6 | def main(): |
— | — | @@ -19,25 +19,18 @@ |
20 | 20 | username = args[0] |
21 | 21 | |
22 | 22 | # Set a random password for the user |
23 | | - passwdargs = ['/usr/local/bin/change-ldap-passwd', '--random', username] |
| 23 | + passwdargs = ['/usr/local/sbin/change-ldap-passwd', '--random', username] |
24 | 24 | passwd = subprocess.Popen(passwdargs, stdout=subprocess.PIPE).communicate()[0] |
25 | 25 | |
26 | 26 | # Set the user's CN and email address |
27 | | - passwdargs = ['/usr/local/bin/modify-ldap-user', '--cn=' + options.wikiname, '--mail=' + options.mail, username] |
| 27 | + passwdargs = ['/usr/local/sbin/modify-ldap-user', '--cn=' + options.wikiname, '--mail=' + options.mail, username] |
28 | 28 | ignore = subprocess.Popen(passwdargs, stdout=subprocess.PIPE).communicate()[0] |
29 | 29 | |
30 | 30 | # Do an initial log in as the user, which will cause the wiki to create an account |
31 | 31 | # for the user. |
32 | | - data = {'action': 'login', |
33 | | - 'lgname': username, |
34 | | - 'lgpassword': passwd, |
35 | | - 'lgdomain': scriptconfig.domain |
36 | | - } |
37 | | - postdata = urllib.urlencode(data) |
38 | | - resp = urllib.urlopen(scriptconfig.controllerapiurl, data=postdata) |
39 | | - if resp.code != 200: |
40 | | - print resp.read() |
41 | | - resp.close() |
| 32 | + url = urlparse.urlparse(scriptconfig.controllerapiurl) |
| 33 | + site = mwclient.Site((url.scheme, url.hostname)) |
| 34 | + site.login(username, passwd, domain=scriptconfig.domain) |
42 | 35 | |
43 | 36 | if __name__ == "__main__": |
44 | 37 | main() |