diff options
author | Jan Cholasta <jcholast@redhat.com> | 2014-03-27 17:52:45 +0100 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2014-04-18 14:59:20 +0200 |
commit | a8dd7aa337f25abd938a582d0fcba51d3b356410 (patch) | |
tree | d2049d4bea9d3927b1d837fa49046b9ca493529c /ipalib | |
parent | b4860d09b4c343e5dd33e7e5e81f09e935002968 (diff) | |
download | freeipa-a8dd7aa337f25abd938a582d0fcba51d3b356410.tar.gz freeipa-a8dd7aa337f25abd938a582d0fcba51d3b356410.tar.xz freeipa-a8dd7aa337f25abd938a582d0fcba51d3b356410.zip |
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 <tbabej@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/plugins/baseldap.py | 11 |
1 files changed, 10 insertions, 1 deletions
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): |