summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-08-30 07:23:06 +1000
committerAndrew Tridgell <tridge@samba.org>2008-08-30 07:23:06 +1000
commitcf37126ac7b833a3a739b151157c296afc0c979c (patch)
tree1a44ed9a699567cc317bc7fb7c2e315c5e16b0a8
parent3441ea5df5b750442d17b90de73d392d2d802ab1 (diff)
downloadsamba-cf37126ac7b833a3a739b151157c296afc0c979c.tar.gz
added a simple script for setting password expiry
-rwxr-xr-xsource/setup/setexpiry44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/setup/setexpiry b/source/setup/setexpiry
new file mode 100755
index 00000000000..e47330510ca
--- /dev/null
+++ b/source/setup/setexpiry
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+#
+# set the password expiry for a user
+# Copyright Andrew Tridgell 2005
+# Copyright Jelmer Vernooij 2008
+# Released under the GNU GPL version 3 or later
+#
+
+import sys
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
+import samba.getopt as options
+import optparse
+from getpass import getpass
+from samba.auth import system_session
+
+parser = optparse.OptionParser("setexpiry [options] <username>")
+sambaopts = options.SambaOptions(parser)
+parser.add_option_group(sambaopts)
+parser.add_option_group(options.VersionOptions(parser))
+credopts = options.CredentialsOptions(parser)
+parser.add_option_group(credopts)
+parser.add_option("--days", help="Days to expiry", type=int)
+parser.add_option("--noexpiry", help="Never expire", action="store_true")
+
+opts, args = parser.parse_args()
+
+if len(args) == 0:
+ parser.print_usage()
+ sys.exit(1)
+
+username = args[0]
+
+lp = sambaopts.get_loadparm()
+creds = credopts.get_credentials(lp)
+
+samdb = sambaopts.get_hostconfig().get_samdb(session_info=system_session(),
+ credentials=creds)
+days = opts.days
+if days is None:
+ days = 0
+samdb.setexpiry(username, days*24*3600, opts.noexpiry)