s4-repl: add a debug to make it easier to monitor replication
[Samba/aatanasov.git] / source4 / setup / setexpiry
blobdb7cdd412fe087250d3521d47be5872fb47ceaad
1 #!/usr/bin/python
3 # Sets the password expiry for a user on a Samba4 server
4 # Copyright Andrew Tridgell 2005
5 # Copyright Jelmer Vernooij 2008
6 # Released under the GNU GPL version 3 or later
9 import sys
11 # Find right directory when running from source tree
12 sys.path.insert(0, "bin/python")
14 import samba.getopt as options
15 import optparse
16 from getpass import getpass
17 from samba.auth import system_session
19 parser = optparse.OptionParser("setexpiry [options] <username>")
20 sambaopts = options.SambaOptions(parser)
21 parser.add_option_group(sambaopts)
22 parser.add_option_group(options.VersionOptions(parser))
23 credopts = options.CredentialsOptions(parser)
24 parser.add_option_group(credopts)
25 parser.add_option("--days", help="Days to expiry", type=int)
26 parser.add_option("--noexpiry", help="Never expire", action="store_true")
28 opts, args = parser.parse_args()
30 if len(args) == 0:
31 parser.print_usage()
32 sys.exit(1)
34 username = args[0]
36 lp = sambaopts.get_loadparm()
37 creds = credopts.get_credentials(lp)
39 samdb = sambaopts.get_hostconfig().get_samdb(session_info=system_session(),
40 credentials=creds)
41 days = opts.days
42 if days is None:
43 days = 0
44 samdb.setexpiry(username, days*24*3600, opts.noexpiry)