summaryrefslogtreecommitdiff
path: root/source4/scripting/python/samba/samdb.py
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/samdb.py
parent7b3d8b6c908a37bb06e413dee406cebd29b99b3e (diff)
downloadsamba-1bc1ac0d084976fccf187526f7bd8d9ad818da10.tar.gz
samba-1bc1ac0d084976fccf187526f7bd8d9ad818da10.tar.bz2
samba-1bc1ac0d084976fccf187526f7bd8d9ad818da10.zip
samba-tool: improved error handling in user setexpiry
Diffstat (limited to 'source4/scripting/python/samba/samdb.py')
-rw-r--r--source4/scripting/python/samba/samdb.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py
index 2cea198e6b..a5c627e5b5 100644
--- a/source4/scripting/python/samba/samdb.py
+++ b/source4/scripting/python/samba/samdb.py
@@ -108,6 +108,8 @@ userAccountControl: %u
"""
res = self.search(base=self.domain_dn(), scope=ldb.SCOPE_SUBTREE,
expression=search_filter, attrs=[])
+ if len(res) == 0:
+ raise Exception('Unable to find user "%s"' % search_filter)
assert(len(res) == 1)
user_dn = res[0].dn
@@ -411,6 +413,8 @@ unicodePwd:: %s
res = self.search(base=self.domain_dn(), scope=ldb.SCOPE_SUBTREE,
expression=search_filter,
attrs=["userAccountControl", "accountExpires"])
+ if len(res) == 0:
+ raise Exception('Unable to find user "%s"' % search_filter)
assert(len(res) == 1)
user_dn = res[0].dn