diff options
author | Jan Cholasta <jcholast@redhat.com> | 2013-03-07 10:50:57 +0100 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2013-03-08 14:47:52 +0100 |
commit | 4152c36bf2943c3e27044e4e9ad7ac24318b14f8 (patch) | |
tree | 69ff4f2d0a7068c8ba7ba03deee9164393c71793 | |
parent | 331856b13c4d73330ac97df9b2815622660f327d (diff) | |
download | freeipa-4152c36bf2943c3e27044e4e9ad7ac24318b14f8.tar.gz freeipa-4152c36bf2943c3e27044e4e9ad7ac24318b14f8.tar.xz freeipa-4152c36bf2943c3e27044e4e9ad7ac24318b14f8.zip |
Do not fail if schema cannot be retrieved from LDAP server.
-rw-r--r-- | ipaserver/ipaldap.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py index 4a4653264..d9f91d538 100644 --- a/ipaserver/ipaldap.py +++ b/ipaserver/ipaldap.py @@ -270,13 +270,19 @@ class IPASimpleLDAPObject(object): self.log = log_mgr.get_logger(self) self.uri = uri self.conn = SimpleLDAPObject(uri) + self._has_schema = False self._schema = None self._force_schema_updates = force_schema_updates def _get_schema(self): - if self._schema is None: - self._schema = schema_cache.get_schema( - self.uri, self.conn, force_update=self._force_schema_updates) + if not self._has_schema: + try: + self._schema = schema_cache.get_schema( + self.uri, self.conn, + force_update=self._force_schema_updates) + except (errors.ExecutionError, IndexError): + pass + self._has_schema = True return self._schema schema = property(_get_schema, None, None, 'schema associated with this LDAP server') @@ -307,6 +313,7 @@ class IPASimpleLDAPObject(object): # logical operations that have the potential to cause a schema # change. + self._has_schema = False self._schema = None def get_syntax(self, attr): @@ -315,6 +322,9 @@ class IPASimpleLDAPObject(object): if syntax is not None: return syntax + if self.schema is None: + return None + # Try to lookup the syntax in the schema returned by the server obj = self.schema.get_obj(ldap.schema.AttributeType, attr) if obj is not None: @@ -708,12 +718,8 @@ class LDAPEntry(dict): else: self._names[name] = name - try: - schema = self._conn.schema - except: - pass - else: - attrtype = schema.get_obj(ldap.schema.AttributeType, + if self._conn.schema is not None: + attrtype = self._conn.schema.get_obj(ldap.schema.AttributeType, name.encode('utf-8')) if attrtype is not None: for altname in attrtype.names: |