summaryrefslogtreecommitdiffstats
path: root/source4/scripting/python/samba/netcmd
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-06-01 14:46:04 +1000
committerAndrew Tridgell <tridge@samba.org>2011-06-01 17:24:36 +1000
commit1bc1ac0d084976fccf187526f7bd8d9ad818da10 (patch)
tree339f36c0e7a8d9c4483310e37ea986de1d79de3c /source4/scripting/python/samba/netcmd
parent7b3d8b6c908a37bb06e413dee406cebd29b99b3e (diff)
downloadsamba-1bc1ac0d084976fccf187526f7bd8d9ad818da10.tar.gz
samba-1bc1ac0d084976fccf187526f7bd8d9ad818da10.tar.xz
samba-1bc1ac0d084976fccf187526f7bd8d9ad818da10.zip
samba-tool: improved error handling in user setexpiry
Diffstat (limited to 'source4/scripting/python/samba/netcmd')
-rw-r--r--source4/scripting/python/samba/netcmd/user.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/source4/scripting/python/samba/netcmd/user.py b/source4/scripting/python/samba/netcmd/user.py
index 15be4bb87fa..6acf52d790f 100644
--- a/source4/scripting/python/samba/netcmd/user.py
+++ b/source4/scripting/python/samba/netcmd/user.py
@@ -151,7 +151,11 @@ class cmd_user_setexpiry(Command):
samdb = SamDB(url=H, session_info=system_session(),
credentials=creds, lp=lp)
- samdb.setexpiry(filter, days*24*3600, no_expiry_req=noexpiry)
+ try:
+ samdb.setexpiry(filter, days*24*3600, no_expiry_req=noexpiry)
+ except Exception, msg:
+ raise CommandError("Failed to set expiry for user %s: %s" % (username or filter, msg))
+ print("Set expiry for user %s to %u days" % (username or filter, days))
class cmd_user(SuperCommand):
"""User management [server connection needed]"""