From a8dd7aa337f25abd938a582d0fcba51d3b356410 Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Thu, 27 Mar 2014 17:52:45 +0100 Subject: Use raw attribute values in command result when --raw is specified. For backward compatibility, the values are converted to unicode, unless the attribute is binary or the conversion fails. Reviewed-By: Tomas Babej --- ipalib/plugins/baseldap.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ipalib/plugins/baseldap.py') diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 949e5753b..cd4910bc1 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -235,7 +235,16 @@ def entry_from_entry(entry, newentry): def entry_to_dict(entry, **options): if options.get('raw', False): - result = dict(entry) + result = {} + for attr, value in entry.raw.iteritems(): + if entry.conn.get_type(attr) is not str: + value = list(value) + for (i, v) in enumerate(value): + try: + value[i] = v.decode('utf-8') + except UnicodeDecodeError: + pass + result[attr] = value else: result = dict((k.lower(), v) for (k, v) in entry.iteritems()) if options.get('all', False): -- cgit