Changeset View
Changeset View
Standalone View
Standalone View
pykolab/cli/cmd_user_info.py
Show All 11 Lines | |||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
# GNU General Public License for more details. | # GNU General Public License for more details. | ||||
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | ||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
# | # | ||||
from __future__ import print_function | |||||
import sys | import sys | ||||
import commands | import commands | ||||
import pykolab | import pykolab | ||||
from pykolab import utils | from pykolab import utils | ||||
from pykolab.translate import _ | from pykolab.translate import _ | ||||
Show All 15 Lines | def execute(*args, **kw): | ||||
result = 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: | if len(user.split('@')) > 1: | ||||
wap_client.system_select_domain(user.split('@')[1]) | wap_client.system_select_domain(user.split('@')[1]) | ||||
user_info = wap_client.user_find({'mail':user}) | user_info = wap_client.user_find({'mail':user}) | ||||
if user_info == None or not user_info: | if user_info == None or not user_info: | ||||
print >> sys.stderr, _("No such user %s") % (user) | print(_("No such user %s") % (user), file=sys.stderr) | ||||
sys.exit(0) | sys.exit(0) | ||||
unic_attrs = ['displayname', 'givenname', 'cn', 'sn', 'ou', 'entrydn'] | unic_attrs = ['displayname', 'givenname', 'cn', 'sn', 'ou', 'entrydn'] | ||||
for (k,v) in user_info.iteritems(): | for (k,v) in user_info.iteritems(): | ||||
if k in unic_attrs: | if k in unic_attrs: | ||||
print "%s: %s" % (k,v) | print("%s: %s" % (k,v)) | ||||
else: | else: | ||||
print "%s: %r" % (k,v) | print("%s: %r" % (k,v)) |