From 8d67acc02609415aacd2cb16979443d9edc0ee22 Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Tue, 10 Dec 2013 11:39:38 +0100 Subject: [PATCH] Make IPASimpleLDAPObject.get_single_value result overridable. Add some default overrides. https://fedorahosted.org/freeipa/ticket/3488 --- ipapython/ipaldap.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py index 2ec5baa7a..3579935ee 100644 --- a/ipapython/ipaldap.py +++ b/ipapython/ipaldap.py @@ -246,11 +246,18 @@ class IPASimpleLDAPObject(object): # # FWIW, many entries under cn=config are undefined :-( - _SCHEMA_OVERRIDE = CIDict({ + _SYNTAX_OVERRIDE = CIDict({ 'managedtemplate': DN_SYNTAX_OID, # DN 'managedbase': DN_SYNTAX_OID, # DN 'originscope': DN_SYNTAX_OID, # DN }) + _SINGLE_VALUE_OVERRIDE = CIDict({ + 'nsslapd-ssl-check-hostname': True, + 'nsslapd-lookthroughlimit': True, + 'nsslapd-idlistscanlimit': True, + 'nsslapd-anonlimitsdn': True, + 'nsslapd-minssf-exclude-rootdse': True, + }) def __init__(self, uri, force_schema_updates, no_schema=False, decode_attrs=True): @@ -327,8 +334,8 @@ class IPASimpleLDAPObject(object): attr = attr.encode('utf-8') # Is this a special case attribute? - if attr in self._SCHEMA_OVERRIDE: - return self._SCHEMA_OVERRIDE[attr] + if attr in self._SYNTAX_OVERRIDE: + return self._SYNTAX_OVERRIDE[attr] if self.schema is None: return None @@ -361,6 +368,9 @@ class IPASimpleLDAPObject(object): if isinstance(attr, unicode): attr = attr.encode('utf-8') + if attr in self._SINGLE_VALUE_OVERRIDE: + return self._SINGLE_VALUE_OVERRIDE[attr] + if self.schema is None: return None