3 # Copyright (c) 2015 Peter Palfrader <peter@palfrader.org>
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be
14 # included in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 from userdir_ldap import *;
27 from string import Template
29 parser = argparse.ArgumentParser(description='Upgrade a guest account.')
30 parser.add_argument('uid', metavar='UID',
31 help="user's uid to be upgraded")
32 args = parser.parse_args()
37 x = l.search_s(BaseBaseDn,ldap.SCOPE_SUBTREE, "uid="+uid, [])
39 print >>sys.stderr, "No hit."
42 print >>sys.stderr, "More than one hit!?"
51 print >> sys.stderr, "Current info:"
52 print >> sys.stderr, dn
55 print >> sys.stderr, " {:<16}: {}".format(a, i)
57 if 'supplementaryGid' not in attrs or 'guest' not in attrs['supplementaryGid']:
58 print >>sys.stderr, "Account is not a guest-account,"
64 print "changetype: modify"
65 print "delete: allowedHost"
67 print "delete: shadowExpire"
69 print "replace: supplementaryGid"
70 for gid in attrs['supplementaryGid']:
71 if gid == "guest": gid = "Debian"
72 print "supplementaryGid:", gid
74 print "add: privateSub"
75 print "privateSub:", uid+"@debian.org"
80 print >> sys.stderr, "Maybe paste (or pipe) this into"
81 print >> sys.stderr, "ldapmodify -ZZ -x -D uid=$USER,ou=users,dc=debian,dc=org -W -h db.debian.org"
85 # vim:set shiftwidth=4: