Permalink
Browse files

Merge pull request #61 from liveaverage/patch-2

Add check for MailADAuthHost existence
  • Loading branch information...
2 parents ca017e3 + 2ef0d23 commit 7c0b3be743b49417ce7630f6af234bd29ef9571c @akissa akissa committed Apr 10, 2013
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/baruwa/auth/ad.py
@@ -269,8 +269,13 @@ def authenticate(self, username=None, password=None):
for host in hosts:
# process all hosts
- # Query each host for configured AD settings:
- adset = MailADAuthHost.objects.get(ad_host=host)
+ # Query each host for configured AD settings:
+ try:
+ adset = MailADAuthHost.objects.get(ad_host=host)
+ aduser = ADUser(username, host.address, host.port, adset.ad_search_dn, adset.ad_admin_group, adset.ad_user_group, adset.ad_auth_domain)
+ except MailADAuthHost.DoesNotExist:
+ logger.warning("No MySQL MailADAuthHost; using setting.py AD config\n")
+ aduser = ADUser(username, host.address, host.port, None, None, None, None)
aduser = ADUser(username, host.address, host.port, adset.ad_search_dn, adset.ad_admin_group, adset.ad_user_group, adset.ad_auth_domain)

0 comments on commit 7c0b3be

Please sign in to comment.