diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2014-12-31 12:26:44 +0100 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2014-12-31 12:26:44 +0100 |
commit | a488e572eaac1719a2abed952e9025b940791b2a (patch) | |
tree | c4bcdd5b47a4b9031c8eba6c76204b4c62e516c5 /pykolab/cli | |
parent | c0dae54be77d34a1aeb4f69cead2ddc45f4fdbe8 (diff) | |
download | pykolab-a488e572eaac1719a2abed952e9025b940791b2a.tar.gz |
Bail out if the user cannot be found
Diffstat (limited to 'pykolab/cli')
-rw-r--r-- | pykolab/cli/cmd_user_info.py | 9 |
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) |