Index: trunk/tools/subversion/user-management/homedirectorymanager.py |
— | — | @@ -4,24 +4,24 @@ |
5 | 5 | from cStringIO import StringIO |
6 | 6 | |
7 | 7 | try: |
8 | | - import ldap |
| 8 | + import ldap |
9 | 9 | import ldap.modlist |
10 | 10 | except ImportError: |
11 | | - sys.stderr.write("Unable to import LDAP library.\n") |
12 | | - sys.exit(1) |
| 11 | + sys.stderr.write("Unable to import LDAP library.\n") |
| 12 | + sys.exit(1) |
13 | 13 | |
14 | 14 | class HomeDirectoryManager: |
15 | 15 | |
16 | | - def __init__(self): |
| 16 | + def __init__(self): |
17 | 17 | ################################################### |
18 | 18 | # Configuration options # |
19 | 19 | ################################################### |
20 | 20 | |
21 | 21 | # Change this if we change the home directory location! |
22 | | - self.basedir = '/home/' |
| 22 | + self.basedir = '/home/' |
23 | 23 | |
24 | 24 | # Directory to move deleted user's home directories |
25 | | - self.savedir = self.basedir + 'SAVE/' |
| 25 | + self.savedir = self.basedir + 'SAVE/' |
26 | 26 | |
27 | 27 | # Add to this array if we add LDAP accounts that shouldn't |
28 | 28 | # have NFS mounted home directories. |
— | — | @@ -63,8 +63,8 @@ |
64 | 64 | ds = ldapSupportLib.connect() |
65 | 65 | self.logDebug("Connected") |
66 | 66 | |
67 | | - # w00t We're in! |
68 | | - try: |
| 67 | + # w00t We're in! |
| 68 | + try: |
69 | 69 | # get all user's uids |
70 | 70 | UsersData = ldapSupportLib.getUsers(ds, '*') |
71 | 71 | self.logDebug("Pulled the user information") |
— | — | @@ -93,19 +93,19 @@ |
94 | 94 | self.createHomeDir(AllUsers) |
95 | 95 | |
96 | 96 | except ldap.UNWILLING_TO_PERFORM, msg: |
97 | | - sys.stderr.write("The search returned an error. Error was: %s\n" % msg[0]["info"]) |
| 97 | + sys.stderr.write("The search returned an error. Error was: %s\n" % msg[0]["info"]) |
98 | 98 | ds.unbind() |
99 | 99 | sys.exit(1) |
100 | | - except Exception: |
| 100 | + except Exception: |
101 | 101 | try: |
102 | | - sys.stderr.write("There was a general error, please contact an administrator via the helpdesk. Please include the following stack trace with your report:\n") |
| 102 | + sys.stderr.write("There was a general error, please contact an administrator via the helpdesk. Please include the following stack trace with your report:\n") |
103 | 103 | traceback.print_exc(file=sys.stderr) |
104 | 104 | ds.unbind() |
105 | 105 | except Exception: |
106 | 106 | pass |
107 | 107 | sys.exit(1) |
108 | 108 | |
109 | | - ds.unbind() |
| 109 | + ds.unbind() |
110 | 110 | sys.exit(0) |
111 | 111 | |
112 | 112 | # Creates home directories for new users. Will not create home directories |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | |
165 | 165 | def uniqueKeys(self, keys): |
166 | 166 | uniqueKeys = [] |
167 | | - [uniqueKeys.append(i) for i in keys if not uniqueKeys.count(i)] |
| 167 | + [uniqueKeys.append(i) for i in keys if not uniqueKeys.count(i)] |
168 | 168 | |
169 | 169 | return uniqueKeys |
170 | 170 | |
Index: trunk/tools/subversion/user-management/modify-ldap-group |
— | — | @@ -3,14 +3,14 @@ |
4 | 4 | from optparse import OptionParser |
5 | 5 | |
6 | 6 | try: |
7 | | - import ldap |
| 7 | + import ldap |
8 | 8 | import ldap.modlist |
9 | 9 | except ImportError: |
10 | | - sys.stderr.write("Unable to import LDAP library.\n") |
11 | | - sys.exit(1) |
| 10 | + sys.stderr.write("Unable to import LDAP library.\n") |
| 11 | + sys.exit(1) |
12 | 12 | |
13 | 13 | def main(): |
14 | | - parser = OptionParser(conflict_handler="resolve") |
| 14 | + parser = OptionParser(conflict_handler="resolve") |
15 | 15 | parser.set_usage('modify-ldap-group [options] <groupname> [--rename <newusergroup>]\nexample: modify-ldap-group --gid=501 wikidev') |
16 | 16 | |
17 | 17 | ldapSupportLib = ldapsupportlib.LDAPSupportLib() |
— | — | @@ -35,8 +35,8 @@ |
36 | 36 | |
37 | 37 | ds = ldapSupportLib.connect() |
38 | 38 | |
39 | | - # w00t We're in! |
40 | | - try: |
| 39 | + # w00t We're in! |
| 40 | + try: |
41 | 41 | groupname = args[0] |
42 | 42 | PosixData = ds.search_s("ou=group," + base,ldap.SCOPE_SUBTREE,"(&(objectclass=posixGroup)(cn=" + groupname + "))") |
43 | 43 | if not PosixData: |
— | — | @@ -70,13 +70,13 @@ |
71 | 71 | # uniqueMember expects DNs |
72 | 72 | if 'uniqueMember' in NewPosixData.keys(): |
73 | 73 | if membertoadd in NewPosixData['uniqueMember']: |
74 | | - sys.stderr.write(raw_member + " is already a member of the group, skipping.\n") |
| 74 | + sys.stderr.write(raw_member + " is already a member of the group, skipping.\n") |
75 | 75 | else: |
76 | 76 | NewPosixData['uniqueMember'].append(membertoadd) |
77 | 77 | else: |
78 | 78 | NewPosixData['uniqueMember'] = [ membertoadd ] |
79 | 79 | except KeyError: |
80 | | - sys.stderr.write(raw_member + " doesn't exist, and won't be added to the group.\n") |
| 80 | + sys.stderr.write(raw_member + " doesn't exist, and won't be added to the group.\n") |
81 | 81 | elif options.deleteMembers: |
82 | 82 | raw_members = options.deleteMembers.split(',') |
83 | 83 | for raw_member in raw_members: |
— | — | @@ -85,21 +85,21 @@ |
86 | 86 | if membertoremove in NewPosixData['uniqueMember']: |
87 | 87 | NewPosixData['uniqueMember'].remove(membertoremove) |
88 | 88 | else: |
89 | | - sys.stderr.write(raw_member + " isn't a member of the group, skipping.\n") |
| 89 | + sys.stderr.write(raw_member + " isn't a member of the group, skipping.\n") |
90 | 90 | else: |
91 | | - sys.stderr.write("This group contains no members.\n") |
| 91 | + sys.stderr.write("This group contains no members.\n") |
92 | 92 | |
93 | 93 | if PosixData == NewPosixData: |
94 | | - sys.stderr.write("No changes to make; exiting.\n") |
| 94 | + sys.stderr.write("No changes to make; exiting.\n") |
95 | 95 | else: |
96 | 96 | modlist = ldap.modlist.modifyModlist(PosixData,NewPosixData) |
97 | 97 | ds.modify_s(dn, modlist) |
98 | 98 | except ldap.UNWILLING_TO_PERFORM, msg: |
99 | | - sys.stderr.write("LDAP was unwilling to modify the group. Error was: %s\n" % msg[0]["info"]) |
| 99 | + sys.stderr.write("LDAP was unwilling to modify the group. Error was: %s\n" % msg[0]["info"]) |
100 | 100 | ds.unbind() |
101 | 101 | sys.exit(1) |
102 | 102 | except ldap.NO_SUCH_OBJECT: |
103 | | - sys.stderr.write("The group you are trying to modify doesn't exist.\n") |
| 103 | + sys.stderr.write("The group you are trying to modify doesn't exist.\n") |
104 | 104 | ds.unbind() |
105 | 105 | sys.exit(1) |
106 | 106 | except ldap.TYPE_OR_VALUE_EXISTS: |
— | — | @@ -111,17 +111,17 @@ |
112 | 112 | traceback.print_exc(file=sys.stderr) |
113 | 113 | ds.unbind() |
114 | 114 | sys.exit(1) |
115 | | - except Exception: |
| 115 | + except Exception: |
116 | 116 | try: |
117 | | - sys.stderr.write("There was a general error, this is unexpected; see traceback.\n") |
| 117 | + sys.stderr.write("There was a general error, this is unexpected; see traceback.\n") |
118 | 118 | traceback.print_exc(file=sys.stderr) |
119 | 119 | ds.unbind() |
120 | 120 | except Exception: |
121 | | - sys.stderr.write("Also failed to unbind.\n") |
| 121 | + sys.stderr.write("Also failed to unbind.\n") |
122 | 122 | traceback.print_exc(file=sys.stderr) |
123 | 123 | sys.exit(1) |
124 | 124 | |
125 | | - ds.unbind() |
| 125 | + ds.unbind() |
126 | 126 | sys.exit(0) |
127 | 127 | |
128 | 128 | if __name__ == "__main__": |
Index: trunk/tools/subversion/user-management/add-ldap-group |
— | — | @@ -3,14 +3,14 @@ |
4 | 4 | from optparse import OptionParser |
5 | 5 | |
6 | 6 | try: |
7 | | - import ldap |
| 7 | + import ldap |
8 | 8 | import ldap.modlist |
9 | 9 | except ImportError: |
10 | | - sys.stderr.write("Unable to import LDAP library.\n") |
11 | | - sys.exit(1) |
| 10 | + sys.stderr.write("Unable to import LDAP library.\n") |
| 11 | + sys.exit(1) |
12 | 12 | |
13 | 13 | def main(): |
14 | | - parser = OptionParser(conflict_handler="resolve") |
| 14 | + parser = OptionParser(conflict_handler="resolve") |
15 | 15 | parser.set_usage('add-ldap-group [options] <groupname>\nexample: add-ldap-group wikidev') |
16 | 16 | |
17 | 17 | ldapSupportLib = ldapsupportlib.LDAPSupportLib() |
— | — | @@ -30,8 +30,8 @@ |
31 | 31 | |
32 | 32 | ds = ldapSupportLib.connect() |
33 | 33 | |
34 | | - # w00t We're in! |
35 | | - try: |
| 34 | + # w00t We're in! |
| 35 | + try: |
36 | 36 | groupname = args[0] |
37 | 37 | |
38 | 38 | dn = 'cn=' + groupname + ',ou=group,' + base |
— | — | @@ -67,7 +67,7 @@ |
68 | 68 | # uniqueMember expects DNs |
69 | 69 | members.append('uid=' + raw_member + ',ou=people,' + base) |
70 | 70 | except KeyError: |
71 | | - sys.stderr.write(raw_member + " doesn't exist, and won't be added to the group.\n") |
| 71 | + sys.stderr.write(raw_member + " doesn't exist, and won't be added to the group.\n") |
72 | 72 | |
73 | 73 | groupEntry = {} |
74 | 74 | groupEntry['objectclass'] = objectClasses |
— | — | @@ -79,11 +79,11 @@ |
80 | 80 | modlist = ldap.modlist.addModlist(groupEntry) |
81 | 81 | ds.add_s(dn, modlist) |
82 | 82 | except ldap.UNWILLING_TO_PERFORM, msg: |
83 | | - sys.stderr.write("LDAP was unwilling to create the group. Error was: %s\n" % msg[0]["info"]) |
| 83 | + sys.stderr.write("LDAP was unwilling to create the group. Error was: %s\n" % msg[0]["info"]) |
84 | 84 | ds.unbind() |
85 | 85 | sys.exit(1) |
86 | 86 | except ldap.TYPE_OR_VALUE_EXISTS: |
87 | | - sys.stderr.write("The group or gid you are trying to add already exists.\n") |
| 87 | + sys.stderr.write("The group or gid you are trying to add already exists.\n") |
88 | 88 | traceback.print_exc(file=sys.stderr) |
89 | 89 | ds.unbind() |
90 | 90 | sys.exit(1) |
— | — | @@ -92,17 +92,17 @@ |
93 | 93 | traceback.print_exc(file=sys.stderr) |
94 | 94 | ds.unbind() |
95 | 95 | sys.exit(1) |
96 | | - except Exception: |
| 96 | + except Exception: |
97 | 97 | try: |
98 | | - sys.stderr.write("There was a general error, this is unexpected; see traceback.\n") |
| 98 | + sys.stderr.write("There was a general error, this is unexpected; see traceback.\n") |
99 | 99 | traceback.print_exc(file=sys.stderr) |
100 | 100 | ds.unbind() |
101 | 101 | except Exception: |
102 | | - sys.stderr.write("Also failed to unbind.\n") |
| 102 | + sys.stderr.write("Also failed to unbind.\n") |
103 | 103 | traceback.print_exc(file=sys.stderr) |
104 | 104 | sys.exit(1) |
105 | 105 | |
106 | | - ds.unbind() |
| 106 | + ds.unbind() |
107 | 107 | sys.exit(0) |
108 | 108 | |
109 | 109 | if __name__ == "__main__": |
Index: trunk/tools/subversion/user-management/netgroup-mod |
— | — | @@ -3,14 +3,14 @@ |
4 | 4 | from optparse import OptionParser |
5 | 5 | |
6 | 6 | try: |
7 | | - import ldap |
| 7 | + import ldap |
8 | 8 | import ldap.modlist |
9 | 9 | except ImportError: |
10 | | - sys.stderr.write("Unable to import LDAP library.\n") |
11 | | - sys.exit(1) |
| 10 | + sys.stderr.write("Unable to import LDAP library.\n") |
| 11 | + sys.exit(1) |
12 | 12 | |
13 | 13 | def main(): |
14 | | - parser = OptionParser(conflict_handler="resolve") |
| 14 | + parser = OptionParser(conflict_handler="resolve") |
15 | 15 | parser.set_usage('netgroup-mod [options] netgroup-name [host|-u user] [-f|--file filename]\n\nexample: netgroup-mod "test-ng" "fenari.wikimedia.org"\nexample: netgroup-mod "test-ng" -f test.file') |
16 | 16 | |
17 | 17 | ldapSupportLib = ldapsupportlib.LDAPSupportLib() |
— | — | @@ -35,8 +35,8 @@ |
36 | 36 | |
37 | 37 | ds = ldapSupportLib.connect() |
38 | 38 | |
39 | | - # w00t We're in! |
40 | | - try: |
| 39 | + # w00t We're in! |
| 40 | + try: |
41 | 41 | if options.hosts: |
42 | 42 | PosixData = ds.search_s("ou=hosts," + base,ldap.SCOPE_SUBTREE,"(&(objectclass=iphost)(cn=*))") |
43 | 43 | elif options.netgroups: |
— | — | @@ -152,58 +152,58 @@ |
153 | 153 | ds.unbind() |
154 | 154 | sys.exit(1) |
155 | 155 | except ldap.UNWILLING_TO_PERFORM, msg: |
156 | | - sys.stderr.write("The search returned an error. Error was: %s\n" % msg[0]["info"]) |
| 156 | + sys.stderr.write("The search returned an error. Error was: %s\n" % msg[0]["info"]) |
157 | 157 | ds.unbind() |
158 | 158 | sys.exit(1) |
159 | | - except ldap.NO_SUCH_OBJECT: |
160 | | - sys.stderr.write("The netgroup provided cannot be found, please try again.\n") |
| 159 | + except ldap.NO_SUCH_OBJECT: |
| 160 | + sys.stderr.write("The netgroup provided cannot be found, please try again.\n") |
161 | 161 | ds.unbind() |
162 | 162 | sys.exit(1) |
163 | 163 | except ldap.TYPE_OR_VALUE_EXISTS: |
164 | | - sys.stderr.write("The host/user you are trying to add is already in the netgroup you provided.\n") |
| 164 | + sys.stderr.write("The host/user you are trying to add is already in the netgroup you provided.\n") |
165 | 165 | ds.unbind() |
166 | 166 | sys.exit(1) |
167 | 167 | except ldap.PROTOCOL_ERROR: |
168 | 168 | if options.delete: |
169 | | - sys.stderr.write("The host/user you are trying to remove is not in the netgroup you provided.\n") |
| 169 | + sys.stderr.write("The host/user you are trying to remove is not in the netgroup you provided.\n") |
170 | 170 | else: |
171 | 171 | sys.stderr.write("There was an LDAP protocol error, please contact an administrator via the helpdesk.\n") |
172 | 172 | ds.unbind() |
173 | 173 | sys.exit(1) |
174 | | - #except Exception: |
| 174 | + #except Exception: |
175 | 175 | # try: |
176 | 176 | # ds.unbind() |
177 | | - # sys.stderr.write("There was a general error, please contact an administrator via the helpdesk.\n") |
| 177 | + # sys.stderr.write("There was a general error, please contact an administrator via the helpdesk.\n") |
178 | 178 | # except Exception: |
179 | 179 | # pass |
180 | 180 | # sys.exit(1) |
181 | 181 | |
182 | | - # /End of stolen stuff |
| 182 | + # /End of stolen stuff |
183 | 183 | |
184 | | - # PosixData is a list of lists where: |
185 | | - # index 0 of PosixData[N]: contains the distinquished name |
186 | | - # index 1 of PosixData[N]: contains a dictionary of lists hashed by the following keys: |
187 | | - # telephoneNumber, departmentNumber, uid, objectClass, loginShell, |
188 | | - # uidNumber, gidNumber, sn, homeDirectory, givenName, cn |
| 184 | + # PosixData is a list of lists where: |
| 185 | + # index 0 of PosixData[N]: contains the distinquished name |
| 186 | + # index 1 of PosixData[N]: contains a dictionary of lists hashed by the following keys: |
| 187 | + # telephoneNumber, departmentNumber, uid, objectClass, loginShell, |
| 188 | + # uidNumber, gidNumber, sn, homeDirectory, givenName, cn |
189 | 189 | |
190 | 190 | if options.hosts or options.netgroups: |
191 | | - for i in range(len(PosixData)): |
192 | | - if options.hosts: |
193 | | - print "hostname: " + PosixData[i][1]["cn"][0] |
194 | | - print " IP: " + PosixData[i][1]["ipHostNumber"][0] |
195 | | - elif options.netgroups: |
196 | | - if not (options.showhost or options.showshares or options.showuser): |
197 | | - print "Netgroup Name: " + PosixData[i][1]["cn"][0] |
198 | | - else: |
199 | | - if options.showhost: |
200 | | - if "ou=host" in PosixData[i][0]: |
201 | | - print "Netgroup Name: " + PosixData[i][1]["cn"][0] |
202 | | - if options.showshares: |
203 | | - if "ou=shares" in PosixData[i][0]: |
204 | | - print "Netgroup Name: " + PosixData[i][1]["cn"][0] |
205 | | - if options.showuser: |
206 | | - if "ou=user" in PosixData[i][0]: |
207 | | - print "Netgroup Name: " + PosixData[i][1]["cn"][0] |
| 191 | + for i in range(len(PosixData)): |
| 192 | + if options.hosts: |
| 193 | + print "hostname: " + PosixData[i][1]["cn"][0] |
| 194 | + print " IP: " + PosixData[i][1]["ipHostNumber"][0] |
| 195 | + elif options.netgroups: |
| 196 | + if not (options.showhost or options.showshares or options.showuser): |
| 197 | + print "Netgroup Name: " + PosixData[i][1]["cn"][0] |
| 198 | + else: |
| 199 | + if options.showhost: |
| 200 | + if "ou=host" in PosixData[i][0]: |
| 201 | + print "Netgroup Name: " + PosixData[i][1]["cn"][0] |
| 202 | + if options.showshares: |
| 203 | + if "ou=shares" in PosixData[i][0]: |
| 204 | + print "Netgroup Name: " + PosixData[i][1]["cn"][0] |
| 205 | + if options.showuser: |
| 206 | + if "ou=user" in PosixData[i][0]: |
| 207 | + print "Netgroup Name: " + PosixData[i][1]["cn"][0] |
208 | 208 | else: |
209 | 209 | if options.user: |
210 | 210 | netgrouptype = "user" |
— | — | @@ -214,15 +214,15 @@ |
215 | 215 | else: |
216 | 216 | print "The " + netgrouptype + "(s) were successfully added." |
217 | 217 | |
218 | | - ds.unbind() |
| 218 | + ds.unbind() |
219 | 219 | sys.exit(0) |
220 | 220 | |
221 | 221 | def checkargs(options, args): |
222 | 222 | if (len(args) < 2 or len(args) > 2): |
223 | 223 | if options.file and len(args) == 1: |
224 | 224 | return |
225 | | - sys.stderr.write("Invalid syntax, please see \"netgroup-mod --help\"\n") |
226 | | - sys.exit(1) |
| 225 | + sys.stderr.write("Invalid syntax, please see \"netgroup-mod --help\"\n") |
| 226 | + sys.exit(1) |
227 | 227 | |
228 | 228 | def infofromfile(list, changetype, file, netgrouptype, PosixCheckData): |
229 | 229 | f = open(file) |
Index: trunk/tools/subversion/user-management/change-ldap-passwd |
— | — | @@ -3,14 +3,14 @@ |
4 | 4 | from optparse import OptionParser |
5 | 5 | |
6 | 6 | try: |
7 | | - import ldap |
| 7 | + import ldap |
8 | 8 | import ldap.modlist |
9 | 9 | except ImportError: |
10 | | - sys.stderr.write("Unable to import LDAP library.\n") |
11 | | - sys.exit(1) |
| 10 | + sys.stderr.write("Unable to import LDAP library.\n") |
| 11 | + sys.exit(1) |
12 | 12 | |
13 | 13 | def main(): |
14 | | - parser = OptionParser(conflict_handler="resolve") |
| 14 | + parser = OptionParser(conflict_handler="resolve") |
15 | 15 | parser.set_usage('change-ldap-passwd [options] <username>') |
16 | 16 | |
17 | 17 | ldapSupportLib = ldapsupportlib.LDAPSupportLib() |
— | — | @@ -28,8 +28,8 @@ |
29 | 29 | |
30 | 30 | ds = ldapSupportLib.connect() |
31 | 31 | |
32 | | - # w00t We're in! |
33 | | - try: |
| 32 | + # w00t We're in! |
| 33 | + try: |
34 | 34 | username = args[0] |
35 | 35 | dn = 'uid=' + username + ',ou=people,' + base |
36 | 36 | while True: |
— | — | @@ -42,11 +42,11 @@ |
43 | 43 | mod_attrs = [( ldap.MOD_REPLACE, 'userPassword', newpass )] |
44 | 44 | ds.modify_s(dn, mod_attrs) |
45 | 45 | except ldap.UNWILLING_TO_PERFORM, msg: |
46 | | - sys.stderr.write("LDAP was unwilling to change the user's password. Error was: %s\n" % msg[0]["info"]) |
| 46 | + sys.stderr.write("LDAP was unwilling to change the user's password. Error was: %s\n" % msg[0]["info"]) |
47 | 47 | ds.unbind() |
48 | 48 | sys.exit(1) |
49 | 49 | except ldap.NO_SUCH_OBJECT: |
50 | | - sys.stderr.write("The user you are trying to modify does not exists.\n") |
| 50 | + sys.stderr.write("The user you are trying to modify does not exists.\n") |
51 | 51 | ds.unbind() |
52 | 52 | sys.exit(1) |
53 | 53 | except ldap.PROTOCOL_ERROR: |
— | — | @@ -54,17 +54,17 @@ |
55 | 55 | traceback.print_exc(file=sys.stderr) |
56 | 56 | ds.unbind() |
57 | 57 | sys.exit(1) |
58 | | - except Exception: |
| 58 | + except Exception: |
59 | 59 | try: |
60 | | - sys.stderr.write("There was a general error, this is unexpected; see traceback.\n") |
| 60 | + sys.stderr.write("There was a general error, this is unexpected; see traceback.\n") |
61 | 61 | traceback.print_exc(file=sys.stderr) |
62 | 62 | ds.unbind() |
63 | 63 | except Exception: |
64 | | - sys.stderr.write("Also failed to unbind.\n") |
| 64 | + sys.stderr.write("Also failed to unbind.\n") |
65 | 65 | traceback.print_exc(file=sys.stderr) |
66 | 66 | sys.exit(1) |
67 | 67 | |
68 | | - ds.unbind() |
| 68 | + ds.unbind() |
69 | 69 | sys.exit(0) |
70 | 70 | |
71 | 71 | if __name__ == "__main__": |
Index: trunk/tools/subversion/user-management/delete-ldap-group |
— | — | @@ -3,14 +3,14 @@ |
4 | 4 | from optparse import OptionParser |
5 | 5 | |
6 | 6 | try: |
7 | | - import ldap |
| 7 | + import ldap |
8 | 8 | import ldap.modlist |
9 | 9 | except ImportError: |
10 | | - sys.stderr.write("Unable to import LDAP library.\n") |
11 | | - sys.exit(1) |
| 10 | + sys.stderr.write("Unable to import LDAP library.\n") |
| 11 | + sys.exit(1) |
12 | 12 | |
13 | 13 | def main(): |
14 | | - parser = OptionParser(conflict_handler="resolve") |
| 14 | + parser = OptionParser(conflict_handler="resolve") |
15 | 15 | parser.set_usage('delete-ldap-group [options] <username>') |
16 | 16 | |
17 | 17 | ldapSupportLib = ldapsupportlib.LDAPSupportLib() |
— | — | @@ -28,17 +28,17 @@ |
29 | 29 | |
30 | 30 | ds = ldapSupportLib.connect() |
31 | 31 | |
32 | | - # w00t We're in! |
33 | | - try: |
| 32 | + # w00t We're in! |
| 33 | + try: |
34 | 34 | groupname = args[0] |
35 | 35 | dn = 'cn=' + groupname + ',ou=group,' + base |
36 | 36 | ds.delete_s(dn) |
37 | 37 | except ldap.UNWILLING_TO_PERFORM, msg: |
38 | | - sys.stderr.write("LDAP was unwilling to delete the group. Error was: %s\n" % msg[0]["info"]) |
| 38 | + sys.stderr.write("LDAP was unwilling to delete the group. Error was: %s\n" % msg[0]["info"]) |
39 | 39 | ds.unbind() |
40 | 40 | sys.exit(1) |
41 | 41 | except ldap.NO_SUCH_OBJECT: |
42 | | - sys.stderr.write("The group you are trying to delete does not exists.\n") |
| 42 | + sys.stderr.write("The group you are trying to delete does not exists.\n") |
43 | 43 | ds.unbind() |
44 | 44 | sys.exit(1) |
45 | 45 | except ldap.PROTOCOL_ERROR: |
— | — | @@ -46,17 +46,17 @@ |
47 | 47 | traceback.print_exc(file=sys.stderr) |
48 | 48 | ds.unbind() |
49 | 49 | sys.exit(1) |
50 | | - except Exception: |
| 50 | + except Exception: |
51 | 51 | try: |
52 | | - sys.stderr.write("There was a general error, this is unexpected; see traceback.\n") |
| 52 | + sys.stderr.write("There was a general error, this is unexpected; see traceback.\n") |
53 | 53 | traceback.print_exc(file=sys.stderr) |
54 | 54 | ds.unbind() |
55 | 55 | except Exception: |
56 | | - sys.stderr.write("Also failed to unbind.\n") |
| 56 | + sys.stderr.write("Also failed to unbind.\n") |
57 | 57 | traceback.print_exc(file=sys.stderr) |
58 | 58 | sys.exit(1) |
59 | 59 | |
60 | | - ds.unbind() |
| 60 | + ds.unbind() |
61 | 61 | sys.exit(0) |
62 | 62 | |
63 | 63 | if __name__ == "__main__": |
Index: trunk/tools/subversion/user-management/ldapsupportlib.py |
— | — | @@ -2,10 +2,10 @@ |
3 | 3 | import os, traceback, getpass, sys |
4 | 4 | |
5 | 5 | try: |
6 | | - import ldap |
| 6 | + import ldap |
7 | 7 | except ImportError: |
8 | | - sys.stderr.write("Unable to import LDAP library.\n") |
9 | | - sys.exit(1) |
| 8 | + sys.stderr.write("Unable to import LDAP library.\n") |
| 9 | + sys.exit(1) |
10 | 10 | |
11 | 11 | class LDAPSupportLib: |
12 | 12 | |
Index: trunk/tools/subversion/user-management/delete-ldap-user |
— | — | @@ -3,14 +3,14 @@ |
4 | 4 | from optparse import OptionParser |
5 | 5 | |
6 | 6 | try: |
7 | | - import ldap |
| 7 | + import ldap |
8 | 8 | import ldap.modlist |
9 | 9 | except ImportError: |
10 | | - sys.stderr.write("Unable to import LDAP library.\n") |
11 | | - sys.exit(1) |
| 10 | + sys.stderr.write("Unable to import LDAP library.\n") |
| 11 | + sys.exit(1) |
12 | 12 | |
13 | 13 | def main(): |
14 | | - parser = OptionParser(conflict_handler="resolve") |
| 14 | + parser = OptionParser(conflict_handler="resolve") |
15 | 15 | parser.set_usage('delete-ldap-user [options] <username>') |
16 | 16 | |
17 | 17 | ldapSupportLib = ldapsupportlib.LDAPSupportLib() |
— | — | @@ -29,8 +29,8 @@ |
30 | 30 | |
31 | 31 | ds = ldapSupportLib.connect() |
32 | 32 | |
33 | | - # w00t We're in! |
34 | | - try: |
| 33 | + # w00t We're in! |
| 34 | + try: |
35 | 35 | username = args[0] |
36 | 36 | dn = 'uid=' + username + ',ou=people,' + base |
37 | 37 | ds.delete_s(dn) |
— | — | @@ -39,11 +39,11 @@ |
40 | 40 | hdm = homedirectorymanager.HomeDirectoryManager() |
41 | 41 | hdm.deleteUser(username) |
42 | 42 | except ldap.UNWILLING_TO_PERFORM, msg: |
43 | | - sys.stderr.write("LDAP was unwilling to delete the user. Error was: %s\n" % msg[0]["info"]) |
| 43 | + sys.stderr.write("LDAP was unwilling to delete the user. Error was: %s\n" % msg[0]["info"]) |
44 | 44 | ds.unbind() |
45 | 45 | sys.exit(1) |
46 | 46 | except ldap.NO_SUCH_OBJECT: |
47 | | - sys.stderr.write("The user you are trying to delete does not exists.\n") |
| 47 | + sys.stderr.write("The user you are trying to delete does not exists.\n") |
48 | 48 | ds.unbind() |
49 | 49 | sys.exit(1) |
50 | 50 | except ldap.PROTOCOL_ERROR: |
— | — | @@ -51,17 +51,17 @@ |
52 | 52 | traceback.print_exc(file=sys.stderr) |
53 | 53 | ds.unbind() |
54 | 54 | sys.exit(1) |
55 | | - except Exception: |
| 55 | + except Exception: |
56 | 56 | try: |
57 | | - sys.stderr.write("There was a general error, this is unexpected; see traceback.\n") |
| 57 | + sys.stderr.write("There was a general error, this is unexpected; see traceback.\n") |
58 | 58 | traceback.print_exc(file=sys.stderr) |
59 | 59 | ds.unbind() |
60 | 60 | except Exception: |
61 | | - sys.stderr.write("Also failed to unbind.\n") |
| 61 | + sys.stderr.write("Also failed to unbind.\n") |
62 | 62 | traceback.print_exc(file=sys.stderr) |
63 | 63 | sys.exit(1) |
64 | 64 | |
65 | | - ds.unbind() |
| 65 | + ds.unbind() |
66 | 66 | sys.exit(0) |
67 | 67 | |
68 | 68 | if __name__ == "__main__": |
Index: trunk/tools/subversion/user-management/ldaplist |
— | — | @@ -3,10 +3,10 @@ |
4 | 4 | from optparse import OptionParser |
5 | 5 | |
6 | 6 | try: |
7 | | - import ldap |
| 7 | + import ldap |
8 | 8 | except ImportError: |
9 | | - sys.stderr.write("Unable to import LDAP library.\n") |
10 | | - sys.exit(1) |
| 9 | + sys.stderr.write("Unable to import LDAP library.\n") |
| 10 | + sys.exit(1) |
11 | 11 | |
12 | 12 | def main(): |
13 | 13 | "An application that implements the functionality of Solaris's ldaplist." |
— | — | @@ -105,23 +105,23 @@ |
106 | 106 | attributes = options.showattributes |
107 | 107 | print "+++ database=" + database |
108 | 108 | print "+++ filter=(&(objectclass=" + objectclass + ")(" + attribute + searchoperator + searchkey + ")) " + attributes |
109 | | - PosixData = ds.search_s(base,ldap.SCOPE_SUBTREE,"(&(objectclass=" + objectclass + ")(" + attribute + searchoperator + searchkey + "))",attrlist) |
| 109 | + PosixData = ds.search_s(base,ldap.SCOPE_SUBTREE,"(&(objectclass=" + objectclass + ")(" + attribute + searchoperator + searchkey + "))",attrlist) |
110 | 110 | else: |
111 | 111 | if options.verbose: |
112 | 112 | print "(objectclass=" + objectclass + ")" |
113 | | - PosixData = ds.search_s(base,ldap.SCOPE_SUBTREE,"(objectclass=" + objectclass + ")") |
| 113 | + PosixData = ds.search_s(base,ldap.SCOPE_SUBTREE,"(objectclass=" + objectclass + ")") |
114 | 114 | except ldap.NO_SUCH_OBJECT: |
115 | | - sys.stderr.write("Object not found. If you are trying to use * in your search, make sure that you wrap your string in single quotes to avoid shell expansion.\n") |
116 | | - ds.unbind() |
117 | | - sys.exit(1) |
| 115 | + sys.stderr.write("Object not found. If you are trying to use * in your search, make sure that you wrap your string in single quotes to avoid shell expansion.\n") |
| 116 | + ds.unbind() |
| 117 | + sys.exit(1) |
118 | 118 | except ldap.PROTOCOL_ERROR: |
119 | | - sys.stderr.write("The search returned a protocol error, this shouldn't ever happen, please submit a trouble ticket.\n") |
120 | | - ds.unbind() |
121 | | - sys.exit(1) |
| 119 | + sys.stderr.write("The search returned a protocol error, this shouldn't ever happen, please submit a trouble ticket.\n") |
| 120 | + ds.unbind() |
| 121 | + sys.exit(1) |
122 | 122 | except Exception: |
123 | | - sys.stderr.write("The search returned an error.\n") |
124 | | - ds.unbind() |
125 | | - sys.exit(1) |
| 123 | + sys.stderr.write("The search returned an error.\n") |
| 124 | + ds.unbind() |
| 125 | + sys.exit(1) |
126 | 126 | |
127 | 127 | PosixData.sort() |
128 | 128 | # /End of stolen stuff |
— | — | @@ -156,9 +156,9 @@ |
157 | 157 | for i in range(len(PosixData)): |
158 | 158 | print "" |
159 | 159 | if not options.longlisting: |
160 | | - print "dn: " + PosixData[i][0] |
| 160 | + print "dn: " + PosixData[i][0] |
161 | 161 | else: |
162 | | - print "dn: " + PosixData[i][0] |
| 162 | + print "dn: " + PosixData[i][0] |
163 | 163 | for (k,v) in PosixData[i][1].items(): |
164 | 164 | if len(v) > 1: |
165 | 165 | for v2 in v: |