summaryrefslogtreecommitdiff
path: root/source4/setup
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-09-08 12:54:13 +1000
committerAndrew Bartlett <abartlet@samba.org>2008-09-08 12:54:13 +1000
commit3eb6f79a02de6820581b91f8d9be80b8dd620119 (patch)
tree3567dccbd6e247f72fe079e4592f0084b1ac0059 /source4/setup
parentdadd59ba401943d0cf5e4d07959456b70a3c11d9 (diff)
parent1efff73068e933dd0b4cc81ff901f6010fda9a6b (diff)
downloadsamba-3eb6f79a02de6820581b91f8d9be80b8dd620119.tar.gz
samba-3eb6f79a02de6820581b91f8d9be80b8dd620119.tar.bz2
samba-3eb6f79a02de6820581b91f8d9be80b8dd620119.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into trusted-domains
(This used to be commit a057c3ed9df2670e5cad5f1807e280d77eb58cb0)
Diffstat (limited to 'source4/setup')
-rwxr-xr-xsource4/setup/setexpiry44
-rwxr-xr-xsource4/setup/tests/blackbox_newuser.sh14
2 files changed, 57 insertions, 1 deletions
diff --git a/source4/setup/setexpiry b/source4/setup/setexpiry
new file mode 100755
index 0000000000..e47330510c
--- /dev/null
+++ b/source4/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)
diff --git a/source4/setup/tests/blackbox_newuser.sh b/source4/setup/tests/blackbox_newuser.sh
index 3e534f2b52..d25c70669b 100755
--- a/source4/setup/tests/blackbox_newuser.sh
+++ b/source4/setup/tests/blackbox_newuser.sh
@@ -15,6 +15,18 @@ shift 1
testit "simple-dc" $PYTHON ./setup/provision --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/simple-dc
-testit "newuser" $PYTHON ./setup/newuser --configfile=$PREFIX/simple-dc/etc/smb.conf testuser testpass
+CONFIG="--configfile=$PREFIX/simple-dc/etc/smb.conf"
+
+testit "newuser" $PYTHON ./setup/newuser $CONFIG testuser testpass
+
+# check the enable account script
+testit "enableaccount" $PYTHON ./setup/enableaccount $CONFIG testuser
+
+# check the enable account script
+testit "setpassword" $PYTHON ./setup/setpassword $CONFIG testuser --newpassword=testpass2
+
+# check the setexpiry script
+testit "noexpiry" $PYTHON ./setup/setexpiry $CONFIG testuser --noexpiry
+testit "expiry" $PYTHON ./setup/setexpiry $CONFIG testuser --days=7
exit $failed