From 142b48558c069cf3e0aff161d359016085057926 Mon Sep 17 00:00:00 2001 From: Chris Hill <53898223+Borgquite@users.noreply.github.com> Date: Wed, 14 Feb 2024 19:44:52 +0000 Subject: [PATCH] DFSNamespaceServerConfiguration: Add EnableSiteCostedReferrals, EnableInsiteReferrals, PreferLogonDC parameters (#134) - DFSNamespaceServerConfiguration - Added support for setting EnableSiteCostedReferrals, EnableInsiteReferrals and PreferLogonDC on a DFS namespace server --- CHANGELOG.md | 11 ++- .../DSC_DFSNamespaceServerConfiguration.psm1 | 63 ++++++++++++- ...DFSNamespaceServerConfiguration.schema.mof | 3 + ..._DFSNamespaceServerConfiguration.Tests.ps1 | 90 +++++++++++++++++++ 4 files changed, 165 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7ff680..774df46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- DFSNamespaceServerConfiguration + - Added support for setting EnableSiteCostedReferrals, EnableInsiteReferrals and PreferLogonDC on a DFS namespace server + +### Fixed + - Updated out of date README.MD. ## [5.0.1] - 2023-09-07 +### Fixed + - DFSDsc - Removed the pipeline files `build.psd1` as it is no longer needed. - + ## [5.0.0] - 2023-09-01 ### Changed diff --git a/source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.psm1 b/source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.psm1 index c77dce5..a353601 100644 --- a/source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.psm1 +++ b/source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.psm1 @@ -22,9 +22,22 @@ data parameterList Name = 'SyncIntervalSec' Type = 'String' }, + @{ + Name = 'EnableSiteCostedReferrals' + Type = 'Boolean' + }, + @{ + Name = 'EnableInsiteReferrals' + Type = 'Boolean' + }, + @{ + Name = 'PreferLogonDC' + Type = 'Boolean' + Restart = $True + }, @{ Name = 'UseFQDN' - Type = 'Uint32' + Type = 'Boolean' Restart = $True } ) @@ -90,6 +103,18 @@ function Get-TargetResource servers and domain controllers connect to the PDC emulator to get updates of DFS namespace metadata. + .PARAMETER EnableSiteCostedReferrals + Indicates whether the server can use cost-based selection. Only + supported for domain-based DFS namespace servers. + + .PARAMETER EnableInsiteReferrals + Indicates whether this server provides only in-site referrals. Only + supported for domain-based DFS namespace servers. + + .PARAMETER PreferLogonDC + Indicates whether to prefer the logon domain controller in referrals. + Only supported for domain-based DFS namespace servers. + .PARAMETER UseFQDN Indicates whether a DFS namespace server uses FQDNs in referrals. #> @@ -111,6 +136,18 @@ function Set-TargetResource [System.UInt32] $SyncIntervalSec, + [Parameter()] + [System.Boolean] + $EnableSiteCostedReferrals, + + [Parameter()] + [System.Boolean] + $EnableInsiteReferrals, + + [Parameter()] + [System.Boolean] + $PreferLogonDC, + [Parameter()] [System.Boolean] $UseFQDN @@ -199,6 +236,18 @@ function Set-TargetResource servers and domain controllers connect to the PDC emulator to get updates of DFS namespace metadata. + .PARAMETER EnableSiteCostedReferrals + Indicates whether the server can use cost-based selection. Only + supported for domain-based DFS namespace servers. + + .PARAMETER EnableInsiteReferrals + Indicates whether this server provides only in-site referrals. Only + supported for domain-based DFS namespace servers. + + .PARAMETER PreferLogonDC + Indicates whether to prefer the logon domain controller in referrals. + Only supported for domain-based DFS namespace servers. + .PARAMETER UseFQDN Indicates whether a DFS namespace server uses FQDNs in referrals. #> @@ -221,6 +270,18 @@ function Test-TargetResource [System.UInt32] $SyncIntervalSec, + [Parameter()] + [System.Boolean] + $EnableSiteCostedReferrals, + + [Parameter()] + [System.Boolean] + $EnableInsiteReferrals, + + [Parameter()] + [System.Boolean] + $PreferLogonDC, + [Parameter()] [System.Boolean] $UseFQDN diff --git a/source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.schema.mof b/source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.schema.mof index 4d5eb73..0d266e4 100644 --- a/source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.schema.mof +++ b/source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.schema.mof @@ -4,5 +4,8 @@ class DSC_DFSNamespaceServerConfiguration : OMI_BaseResource [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'."), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; [Write, Description("Specifies a time-out value, in seconds, for Lightweight Directory Access Protocol (LDAP) requests for the DFS namespace server.")] Uint32 LdapTimeoutSec; [Write, Description("This interval controls how often domain-based DFS namespace root servers and domain controllers connect to the PDC emulator to get updates of DFS namespace metadata.")] Uint32 SyncIntervalSec; + [Write, Description("Indicates whether the server can use cost-based selection. Only supported for domain-based DFS namespace servers.")] Boolean EnableSiteCostedReferrals; + [Write, Description("Indicates whether this server provides only in-site referrals. Only supported for domain-based DFS namespace servers.")] Boolean EnableInsiteReferrals; + [Write, Description("Indicates whether to prefer the logon domain controller in referrals. Only supported for domain-based DFS namespace servers.")] Boolean PreferLogonDC; [Write, Description("Indicates whether a DFS namespace server uses FQDNs in referrals.")] Boolean UseFQDN; }; diff --git a/tests/Unit/DSC_DFSNamespaceServerConfiguration.Tests.ps1 b/tests/Unit/DSC_DFSNamespaceServerConfiguration.Tests.ps1 index 7bec796..1ab47fd 100644 --- a/tests/Unit/DSC_DFSNamespaceServerConfiguration.Tests.ps1 +++ b/tests/Unit/DSC_DFSNamespaceServerConfiguration.Tests.ps1 @@ -68,6 +68,9 @@ try $namespaceServerConfiguration = [PSObject]@{ LdapTimeoutSec = 45 SyncIntervalSec = 5000 + EnableSiteCostedReferrals = $False + EnableInsiteReferrals = $True + PreferLogonDC = $True UseFQDN = $True } @@ -75,6 +78,9 @@ try IsSingleInstance = 'Yes' LdapTimeoutSec = $namespaceServerConfiguration.LdapTimeoutSec SyncIntervalSec = $namespaceServerConfiguration.SyncIntervalSec + EnableSiteCostedReferrals = $namespaceServerConfiguration.EnableSiteCostedReferrals + EnableInsiteReferrals = $namespaceServerConfiguration.EnableInsiteReferrals + PreferLogonDC = $namespaceServerConfiguration.PreferLogonDC UseFQDN = $namespaceServerConfiguration.UseFQDN } @@ -86,6 +92,9 @@ try $result = Get-TargetResource -IsSingleInstance 'Yes' $result.LdapTimeoutSec | Should -Be $namespaceServerConfiguration.LdapTimeoutSec $result.SyncIntervalSec | Should -Be $namespaceServerConfiguration.SyncIntervalSec + $result.EnableSiteCostedReferrals | Should -Be $namespaceServerConfiguration.EnableSiteCostedReferrals + $result.EnableInsiteReferrals | Should -Be $namespaceServerConfiguration.EnableInsiteReferrals + $result.PreferLogonDC | Should -Be $namespaceServerConfiguration.PreferLogonDC $result.UseFQDN | Should -Be $namespaceServerConfiguration.UseFQDN } @@ -143,6 +152,51 @@ try } } + Context 'Namespace Server Configuration EnableSiteCostedReferrals is different' { + It 'Should not throw error' { + { + $splat = $namespaceServerConfigurationSplat.Clone() + $splat.EnableSiteCostedReferrals = -not $splat.EnableSiteCostedReferrals + Set-TargetResource @splat + } | Should -Not -Throw + } + + It 'Should call expected Mocks' { + Assert-MockCalled -commandName Get-DFSNServerConfiguration -Exactly -Times 1 + Assert-MockCalled -commandName Set-DFSNServerConfiguration -Exactly -Times 1 + } + } + + Context 'Namespace Server Configuration EnableInsiteReferrals is different' { + It 'Should not throw error' { + { + $splat = $namespaceServerConfigurationSplat.Clone() + $splat.EnableInsiteReferrals = -not $splat.EnableInsiteReferrals + Set-TargetResource @splat + } | Should -Not -Throw + } + + It 'Should call expected Mocks' { + Assert-MockCalled -commandName Get-DFSNServerConfiguration -Exactly -Times 1 + Assert-MockCalled -commandName Set-DFSNServerConfiguration -Exactly -Times 1 + } + } + + Context 'Namespace Server Configuration PreferLogonDC is different' { + It 'Should not throw error' { + { + $splat = $namespaceServerConfigurationSplat.Clone() + $splat.PreferLogonDC = -not $splat.PreferLogonDC + Set-TargetResource @splat + } | Should -Not -Throw + } + + It 'Should call expected Mocks' { + Assert-MockCalled -commandName Get-DFSNServerConfiguration -Exactly -Times 1 + Assert-MockCalled -commandName Set-DFSNServerConfiguration -Exactly -Times 1 + } + } + Context 'Namespace Server Configuration UseFQDN is different' { It 'Should not throw error' { { @@ -197,6 +251,42 @@ try } } + Context 'Namespace Server Configuration EnableSiteCostedReferrals is different' { + It 'Should return false' { + $splat = $namespaceServerConfigurationSplat.Clone() + $splat.EnableSiteCostedReferrals = -not $splat.EnableSiteCostedReferrals + Test-TargetResource @splat | Should -BeFalse + } + + It 'Should call expected Mocks' { + Assert-MockCalled -commandName Get-DFSNServerConfiguration -Exactly -Times 1 + } + } + + Context 'Namespace Server Configuration EnableInsiteReferrals is different' { + It 'Should return false' { + $splat = $namespaceServerConfigurationSplat.Clone() + $splat.EnableInsiteReferrals = -not $splat.EnableInsiteReferrals + Test-TargetResource @splat | Should -BeFalse + } + + It 'Should call expected Mocks' { + Assert-MockCalled -commandName Get-DFSNServerConfiguration -Exactly -Times 1 + } + } + + Context 'Namespace Server Configuration PreferLogonDC is different' { + It 'Should return false' { + $splat = $namespaceServerConfigurationSplat.Clone() + $splat.PreferLogonDC = -not $splat.PreferLogonDC + Test-TargetResource @splat | Should -BeFalse + } + + It 'Should call expected Mocks' { + Assert-MockCalled -commandName Get-DFSNServerConfiguration -Exactly -Times 1 + } + } + Context 'Namespace Server Configuration UseFQDN is different' { It 'Should return false' { $splat = $namespaceServerConfigurationSplat.Clone()