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
11 # Find right directory when running from source tree
12 sys
.path
.insert(0, "bin/python")
14 import samba
.getopt
as options
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()
36 lp
= sambaopts
.get_loadparm()
37 creds
= credopts
.get_credentials(lp
)
39 samdb
= sambaopts
.get_hostconfig().get_samdb(session_info
=system_session(),
44 samdb
.setexpiry(username
, days
*24*3600, opts
.noexpiry
)