Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: SqlRSSecureConnectionLevel: Remove resource in favor of SqlRS #991

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
## Unreleased

- Changes to SqlServerDsc
- BREAKING CHANGE: Resource SqlRSSecureConnectionLevel was remove
([issue #990](https://github.com/PowerShell/SqlServerDsc/issues/990)).
The parameter that was set using that resource has been merged into resource
SqlRS as the parameter UseSsl. The UseSsl parameter is of type boolean. This
change was made because from SQL Server 2008 R2 this value is made an on/off
switch. Read more in the article [ConfigurationSetting Method - SetSecureConnectionLevel](https://docs.microsoft.com/en-us/sql/reporting-services/wmi-provider-library-reference/configurationsetting-method-setsecureconnectionlevel).
- Updated so that named parameters are used for New-Object cmdlet. This was
done to follow the style guideline.
- Updated manifest and license to reflect the new year
Expand All @@ -19,6 +25,8 @@
- Replaced Get-WmiObject with Get-CimInstance to fix Script Analyzer warnings
([issue #264](https://github.com/PowerShell/SqlServerDsc/issues/264)).
- Refactored the resource to use Invoke-CimMethod.
- Added parameter UseSsl which when set to $true forces connections to the
Reporting Services to use SSL when connecting ([issue #990](https://github.com/PowerShell/SqlServerDsc/issues/990)).
- Changes to SqlServerNetwork
- Added sysadmin account parameter usage to the examples.
- Changes to SqlServerReplication
Expand Down
81 changes: 77 additions & 4 deletions DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,18 @@ function Get-TargetResource

if ( $isInitialized )
{
if ( $reportingServicesData.Configuration.SecureConnectionLevel )
{
$isUsingSsl = $true
}
else
{
$isUsingSsl = $false
}

$reportServerVirtualDirectory = $reportingServicesData.Configuration.VirtualDirectoryReportServer
$reportsVirtualDirectory = $reportingServicesData.Configuration.VirtualDirectoryReportManager

#$reservedUrls = $reportingServicesData.Configuration.ListReservedUrls()

$invokeRsCimMethodParameters = @{
CimInstance = $reportingServicesData.Configuration
MethodName = 'ListReservedUrls'
Expand Down Expand Up @@ -103,6 +110,7 @@ function Get-TargetResource
ReportsVirtualDirectory = $reportsVirtualDirectory
ReportServerReservedUrl = $reportServerReservedUrl
ReportsReservedUrl = $reportsReservedUrl
UseSsl = $isUsingSsl
IsInitialized = $isInitialized
}
}
Expand Down Expand Up @@ -134,6 +142,11 @@ function Get-TargetResource
Report Manager/Report Web App URL reservations. Optional.
If not specified, 'http://+:80' URL reservation will be used.

.PARAMETER UseSsl
If connections to the Reporting Services must use SSL. If this
parameter is not assigned a value, the default is that Reporting
Services does not use SSL.

.NOTES
To find out the parameter names for the methods in the class
MSReportServer_ConfigurationSetting it's easy to list them using the
Expand All @@ -159,6 +172,17 @@ function Get-TargetResource
$reportingServicesData = Get-ReportingServicesData -InstanceName $InstanceName
$reportingServicesData.Configuration.CimClass.CimClassMethods[$methodName].Parameters
```

SecureConnectionLevel (the parameter UseSsl):
The SecureConnectionLevel value can be 0,1,2 or 3, but since
SQL Server 2008 R2 this was changed. So we are just setting it to 0 (off)
and 1 (on).

"In SQL Server 2008 R2, SecureConnectionLevel is made an on/off
switch, default value is 0. For any value greater than or equal
to 1 passed through SetSecureConnectionLevel method API, SSL
is considered on..."
https://docs.microsoft.com/en-us/sql/reporting-services/wmi-provider-library-reference/configurationsetting-method-setsecureconnectionlevel
#>
function Set-TargetResource
{
Expand Down Expand Up @@ -191,7 +215,11 @@ function Set-TargetResource

[Parameter()]
[System.String[]]
$ReportsReservedUrl
$ReportsReservedUrl,

[Parameter()]
[System.Boolean]
$UseSsl
)

$reportingServicesData = Get-ReportingServicesData -InstanceName $InstanceName
Expand Down Expand Up @@ -407,6 +435,21 @@ function Set-TargetResource

Invoke-RsCimMethod @invokeRsCimMethodParameters

if ( $PSBoundParameters.ContainsKey('UseSsl') -and $UseSsl -ne $currentConfig.UseSsl )
{
New-VerboseMessage -Message "Changing value for using SSL to '$UseSsl'."

$invokeRsCimMethodParameters = @{
CimInstance = $reportingServicesData.Configuration
MethodName = 'SetSecureConnectionLevel'
Arguments = @{
Level = @(0,1)[$UseSsl]
}
}

Invoke-RsCimMethod @invokeRsCimMethodParameters
}

Restart-ReportingServicesService -SQLInstanceName $InstanceName
}
else
Expand Down Expand Up @@ -602,6 +645,21 @@ function Set-TargetResource
Invoke-RsCimMethod @invokeRsCimMethodParameters
}
}

if ( $PSBoundParameters.ContainsKey('UseSsl') -and $UseSsl -ne $currentConfig.UseSsl )
{
New-VerboseMessage -Message "Changing value for using SSL to '$UseSsl'."

$invokeRsCimMethodParameters = @{
CimInstance = $reportingServicesData.Configuration
MethodName = 'SetSecureConnectionLevel'
Arguments = @{
Level = @(0,1)[$UseSsl]
}
}

Invoke-RsCimMethod @invokeRsCimMethodParameters
}
}
}

Expand Down Expand Up @@ -637,6 +695,11 @@ function Set-TargetResource
.PARAMETER ReportsReservedUrl
Report Manager/Report Web App URL reservations. Optional.
If not specified, 'http://+:80' URL reservation will be used.

.PARAMETER UseSsl
If connections to the Reporting Services must use SSL. If this
parameter is not assigned a value, the default is that Reporting
Services does not use SSL.
#>
function Test-TargetResource
{
Expand Down Expand Up @@ -670,7 +733,11 @@ function Test-TargetResource

[Parameter()]
[System.String[]]
$ReportsReservedUrl
$ReportsReservedUrl,

[Parameter()]
[System.Boolean]
$UseSsl
)

$result = $true
Expand Down Expand Up @@ -723,6 +790,12 @@ function Test-TargetResource
$result = $false
}

if ( $PSBoundParameters.ContainsKey('UseSsl') -and $UseSsl -ne $currentConfig.UseSsl )
{
New-VerboseMessage -Message "The value for using SSL are not in desired state. Should be '$UseSsl', but was '$($currentConfig.UseSsl)'."
$result = $false
}

$result
}

Expand Down
1 change: 1 addition & 0 deletions DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ class MSFT_SqlRS : OMI_BaseResource
[Write, Description("Report Manager/Report Web App virtual directory name. Optional.")] String ReportsVirtualDirectory;
[Write, Description("Report Server URL reservations. Optional. If not specified, 'http://+:80' URL reservation will be used.")] String ReportServerReservedUrl[];
[Write, Description("Report Manager/Report Web App URL reservations. Optional. If not specified, 'http://+:80' URL reservation will be used.")] String ReportsReservedUrl[];
[Write, Description("If connections to the Reporting Services must use SSL. If this parameter is not assigned a value, the default is that Reporting Services does not use SSL.")] Boolean UseSsl;
[Read, Description("Is the Reporting Services instance initialized.")] Boolean IsInitialized;
};

This file was deleted.

This file was deleted.

10 changes: 5 additions & 5 deletions Examples/Resources/SqlRS/1-DefaultConfiguration.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<#
.EXAMPLE
This example performs a default SSRS configuration. It will initialize SSRS
and register default Report Server Web Service and Report Manager URLs:
This example performs a default SQL Server Reporting Services configuration.
It will initialize SQL Server Reporting Services and register default
Report Server Web Service and Report Manager URLs.

http://localhost:80/ReportServer (Report Server Web Service)

http://localhost:80/Reports (Report Manager)
Report Server Web Service: http://localhost:80/ReportServer
Report Manager: http://localhost:80/Reports
#>
Configuration Example
{
Expand Down
14 changes: 8 additions & 6 deletions Examples/Resources/SqlRS/2-CustomConfiguration.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<#
.EXAMPLE
This example performs a custom SSRS configuration. It will initialize SSRS
and register custom Report Server Web Service and Report Manager URLs:
This example performs a custom SQL Server Reporting Services configuration.
It will initialize SQL Server Reporting Services and register the below
custom Report Server Web Service and Report Manager URLs.

Report Server Web Service:
http://localhost:80/MyReportServer
https://localhost:443/MyReportServer (Report Server Web Service)
https://localhost:443/MyReportServer

Report Manager:
http://localhost:80/MyReports
https://localhost:443/MyReports (Report Manager)
https://localhost:443/MyReports

Please note: this resource does not currently handle SSL bindings for HTTPS
endpoints.
Note: this resource does not currently handle SSL bindings for HTTPS endpoints.
#>
Configuration Example
{
Expand Down
29 changes: 29 additions & 0 deletions Examples/Resources/SqlRS/3-CustomConfigurationUsingSsl.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<#
.EXAMPLE
This example performs a custom SQL Server Reporting Services configuration.
It will initialize SQL Server Reporting Services and register the below
custom Report Server Web Service and Report Manager URLs and enable SSL.

Report Server Web Service: https://localhost:443/MyReportServer ()
Report Manager: https://localhost:443/MyReports

Note: this resource does not currently handle SSL bindings for HTTPS endpoints.
#>
Configuration Example
{
Import-DscResource -ModuleName SqlServerDsc

node localhost {
SqlRS DefaultConfiguration
{
InstanceName = 'MSSQLSERVER'
DatabaseServerName = 'localhost'
DatabaseInstanceName = 'MSSQLSERVER'
ReportServerVirtualDirectory = 'MyReportServer'
ReportsVirtualDirectory = 'MyReports'
ReportServerReservedUrl = @('https://+:443')
ReportsReservedUrl = @('https://+:443')
UseSsl = $true
}
}
}
Loading