summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-12-31 12:26:44 +0100
committerThomas Bruederli <bruederli@kolabsys.com>2015-02-04 08:53:18 +0100
commit0ad7c93a382b673b097bb15b7780d135bcf75668 (patch)
treeff2e2eee9133fe1c0cc301e8c84919bcff77f5f4
parent5bd2125062da20c52f40241e81cd984d29e62b09 (diff)
downloadpykolab-0ad7c93a382b673b097bb15b7780d135bcf75668.tar.gz
Bail out if the user cannot be found
-rw-r--r--pykolab/cli/cmd_user_info.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/pykolab/cli/cmd_user_info.py b/pykolab/cli/cmd_user_info.py
index 1e1e969..c120353 100644
--- a/pykolab/cli/cmd_user_info.py
+++ b/pykolab/cli/cmd_user_info.py
@@ -17,6 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+import sys
+
import commands
import pykolab
@@ -38,11 +40,16 @@ def execute(*args, **kw):
except IndexError, errmsg:
user = utils.ask_question(_("Email address"))
- wap_client.authenticate(username=conf.get("ldap", "bind_dn"), password=conf.get("ldap", "bind_pw"))
+ result = wap_client.authenticate(username=conf.get("ldap", "bind_dn"), password=conf.get("ldap", "bind_pw"))
+
if len(user.split('@')) > 1:
wap_client.system_select_domain(user.split('@')[1])
user_info = wap_client.user_find({'mail':user})
+ if user_info == None or not user_info:
+ print >> sys.stderr, _("No such user %s") % (user)
+ sys.exit(0)
+
for (k,v) in user_info.iteritems():
print "%s: %r" % (k,v)