Skip to content

Commit

Permalink
Handle unknown DNS lookup failure (#80)
Browse files Browse the repository at this point in the history
Handles any exception when failing to lookup the SRV record for the
default realm. The error will still be shown when the value is used but
now the module will still import.
  • Loading branch information
jborean93 authored Mar 28, 2024
1 parent 90f92c2 commit 921e2fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog for PSOpenAD

## v0.5.1 - TBD

+ Ensure a failure in a DNS lookup does not stop the module from importing but only errors when the value is used.

## v0.5.0 - 2024-03-21

+ Added the following cmdlets:
Expand Down
2 changes: 1 addition & 1 deletion module/PSOpenAD.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
RootModule = 'PSOpenAD.psm1'

# Version number of this module.
ModuleVersion = '0.5.0'
ModuleVersion = '0.5.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
6 changes: 5 additions & 1 deletion src/PSOpenAD.Module/OnImportAndRemove.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ public void OnImport()
}
catch (DnsResponseException e)
{
GlobalState.DefaultDCError = $"Error looking up SRV records for _ldap._tcp.{baseDomain}: {e.Message}";
GlobalState.DefaultDCError = $"DNS Error looking up SRV records for _ldap._tcp.{baseDomain}: {e.Message}";
}
catch (Exception e)
{
GlobalState.DefaultDCError = $"Unknown error looking up SRV records for _ldap._tcp.{baseDomain}: {e.GetType().Name} - {e.Message}";
}
}
}
Expand Down

0 comments on commit 921e2fa

Please sign in to comment.