Skip to content

Commit

Permalink
Avoid DNS lookup when disabling AD
Browse files Browse the repository at this point in the history
If DNS lookup fails due to broken networking or domain being
inaccessible then this may fail with a dns.resolver exception and
prevent disabling the activedirectory service.
  • Loading branch information
anodos325 committed Jul 25, 2024
1 parent eb8bf23 commit 77539eb
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/middlewared/middlewared/plugins/activedirectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,20 @@ async def update_netbios_data(self, old, new):

@private
async def common_validate(self, new, old, verrors):
try:
if not (await self.middleware.call('activedirectory.netbiosname_is_ours', new['netbiosname'], new['domainname'], new['dns_timeout'])):
verrors.add(
'activedirectory_update.netbiosname',
f'NetBIOS name [{new["netbiosname"]}] appears to be in use by another computer in Active Directory DNS. '
'Further investigation and DNS corrections will be required prior to using the aforementioned name to '
'join Active Directory.'
)
except CallError:
pass
if new['enable']:
try:
if not (await self.middleware.call(
'activedirectory.netbiosname_is_ours',
new['netbiosname'], new['domainname'], new['dns_timeout'])
):
verrors.add(
'activedirectory_update.netbiosname',
f'NetBIOS name [{new["netbiosname"]}] appears to be in use by another computer in Active Directory DNS. '
'Further investigation and DNS corrections will be required prior to using the aforementioned name to '
'join Active Directory.'
)
except CallError:
pass

if new['kerberos_realm'] and new['kerberos_realm'] != old['kerberos_realm']:
realm = await self.middleware.call('kerberos.realm.query', [("id", "=", new['kerberos_realm'])])
Expand Down

0 comments on commit 77539eb

Please sign in to comment.