summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-08-03 11:53:01 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-08-03 11:53:01 (GMT)
commit553e2c82142f405e772f480ecfc446ff91da17b7 (patch)
tree423e550aa20c84213df0a87aa3ef489b0d83b797
parent612c27d2dfd422790ca3f246951b40ce57d3b530 (diff)
downloadpykolab-553e2c82142f405e772f480ecfc446ff91da17b7.tar.gz
Add a command user-info
-rw-r--r--pykolab/cli/cmd_user_info.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/pykolab/cli/cmd_user_info.py b/pykolab/cli/cmd_user_info.py
new file mode 100644
index 0000000..23fceb8
--- /dev/null
+++ b/pykolab/cli/cmd_user_info.py
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2012 Kolab Systems AG (http://www.kolabsys.com)
+#
+# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 3 or, at your option, any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+import commands
+
+import pykolab
+
+from pykolab import utils
+from pykolab.translate import _
+
+log = pykolab.getLogger('pykolab.cli')
+conf = pykolab.getConf()
+
+def __init__():
+ commands.register('user_info', execute, description="Display user information.")
+
+def execute(*args, **kw):
+ from pykolab import wap_client
+
+ try:
+ user = conf.cli_args.pop(0)
+ except IndexError, errmsg:
+ user = utils.ask_question(_("Email address"))
+
+ 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})
+
+ for (k,v) in user_info.iteritems():
+ print "%s: %r" % (k,v)