diff options
author | Jan Cholasta <jcholast@redhat.com> | 2013-03-07 10:56:03 +0100 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2013-03-08 14:47:52 +0100 |
commit | f423364fa82ff32cb1fe214ddb5f7368cfb346ef (patch) | |
tree | d9c32a81073a3bc84f79e75ccd08b28344b2e97a /ipaserver/ipaldap.py | |
parent | fffd2eb32df63010351ed0f07fd34b411cdaf06e (diff) | |
download | freeipa-f423364fa82ff32cb1fe214ddb5f7368cfb346ef.tar.gz freeipa-f423364fa82ff32cb1fe214ddb5f7368cfb346ef.tar.xz freeipa-f423364fa82ff32cb1fe214ddb5f7368cfb346ef.zip |
Allow disabling attribute decoding in LDAPClient and IPAdmin.
Diffstat (limited to 'ipaserver/ipaldap.py')
-rw-r--r-- | ipaserver/ipaldap.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py index c814f5798..88c6fcc9d 100644 --- a/ipaserver/ipaldap.py +++ b/ipaserver/ipaldap.py @@ -255,7 +255,8 @@ class IPASimpleLDAPObject(object): 'originscope': DN_SYNTAX_OID, # DN }) - def __init__(self, uri, force_schema_updates, no_schema=False): + def __init__(self, uri, force_schema_updates, no_schema=False, + decode_attrs=True): """An internal LDAP connection object :param uri: The LDAP URI to connect to @@ -267,6 +268,9 @@ class IPASimpleLDAPObject(object): 'updates', but it must be given explicitly since the API object is not always available :param no_schema: If true, schema is never requested from the server. + :param decode_attrs: + If true, attributes are decoded to Python types according to their + syntax. """ self.log = log_mgr.get_logger(self) self.uri = uri @@ -275,6 +279,7 @@ class IPASimpleLDAPObject(object): self._has_schema = False self._schema = None self._force_schema_updates = force_schema_updates + self._decode_attrs = decode_attrs def _get_schema(self): if self._no_schema: @@ -377,6 +382,9 @@ class IPASimpleLDAPObject(object): ''' ''' + if not self._decode_attrs: + return values + ipa_values = [] for original_value in values: @@ -1649,7 +1657,8 @@ class IPAdmin(LDAPClient): def __init__(self, host='', port=389, cacert=None, debug=None, ldapi=False, realm=None, protocol=None, force_schema_updates=True, - start_tls=False, ldap_uri=None, no_schema=False): + start_tls=False, ldap_uri=None, no_schema=False, + decode_attrs=True): self.conn = None log_mgr.get_logger(self, True) if debug and debug.lower() == "on": @@ -1670,7 +1679,8 @@ class IPAdmin(LDAPClient): LDAPClient.__init__(self, ldap_uri) self.conn = IPASimpleLDAPObject(ldap_uri, force_schema_updates=True, - no_schema=no_schema) + no_schema=no_schema, + decode_attrs=decode_attrs) if start_tls: self.conn.start_tls_s() |