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 DefaultGroup = getattr(ConfModule, "defaultgroup", 'users')
31 parser = argparse.ArgumentParser(description='Upgrade a guest account.')
32 parser.add_argument('uid', metavar='UID',
33 help="user's uid to be upgraded")
34 args = parser.parse_args()
39 x = l.search_s(BaseBaseDn,ldap.SCOPE_SUBTREE, "uid="+uid, [])
41 print >>sys.stderr, "No hit."
44 print >>sys.stderr, "More than one hit!?"
53 print >> sys.stderr, "Current info:"
54 print >> sys.stderr, dn
57 print >> sys.stderr, " {:<16}: {}".format(a, i)
59 if 'supplementaryGid' not in attrs or 'guest' not in attrs['supplementaryGid']:
60 print >>sys.stderr, "Account is not a guest-account,"
66 print "changetype: modify"
67 print "delete: allowedHost"
69 print "delete: shadowExpire"
71 print "replace: supplementaryGid"
72 for gid in attrs['supplementaryGid']:
73 if gid == "guest": gid = DefaultGroup
74 print "supplementaryGid:", gid
76 print "replace: privateSub"
77 print "privateSub:", uid+"@debian.org"
82 print >> sys.stderr, "Maybe paste (or pipe) this into"
83 print >> sys.stderr, "ldapmodify -ZZ -x -D uid=$USER,ou=users,dc=debian,dc=org -W -h db.debian.org"
87 # vim:set shiftwidth=4: