diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py --- a/pykolab/auth/ldap/__init__.py +++ b/pykolab/auth/ldap/__init__.py @@ -2112,8 +2112,9 @@ # If we have a 1:1 match, continue as planned for naming_context in naming_contexts: - if self.domain_rootdns[domain].endswith(naming_context): - return naming_context + if domain in self.domain_rootdns: + if self.domain_rootdns[domain].endswith(naming_context): + return naming_context def _primary_domain_for_naming_context(self, naming_context): self._bind()