Skip to content

Commit dd68dc7

Browse files
authored
Merge pull request microsoft#254 from robertoandrade/master
CustomAuthentication switch
2 parents bd57f51 + 10602ab commit dd68dc7

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

ReportingServicesTools/Functions/Common/ConnectionObjectRequests.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Credential
1313
- Proxy
1414
- APIVersion
15+
- CustomAuthentication
1516
These parameters are passed on to the New-RsWebServiceProxy function, unless Proxy was specified.
1617
If the bound parameters contain the proxy parameter, the function will return that object.
1718
All other bound parameters are ignored.
@@ -36,7 +37,7 @@
3637
return $BoundParameters["Proxy"]
3738
}
3839

39-
$goodKeys = @("ReportServerUri", "Credential", "ApiVersion")
40+
$goodKeys = @("ReportServerUri", "Credential", "ApiVersion", "CustomAuthentication")
4041
$NewRsWebServiceProxyParam = @{ }
4142

4243
foreach ($key in $BoundParameters.Keys)

ReportingServicesTools/Functions/Utilities/Connect-RsReportServer.ps1

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ function Connect-RsReportServer
3636
The version of the API to use, 2010 by default. Sepcifiy '2005' or '2006' if you need
3737
to query a Sql Server Reporting Service Instance running a version prior to
3838
SQL Server 2008 R2 to access those respective APIs.
39-
39+
40+
.PARAMETER CustomAuthentication
41+
If the server implements a custom authentication schema such as 'Forms' instead of standard Basic/NTLM.
42+
4043
.EXAMPLE
4144
Connect-RsReportServer -ComputerName "srv-foobar" -ReportServerInstance "Northwind" -ReportServerUri "http://srv-foobar/reportserver/"
4245
@@ -79,9 +82,13 @@ function Connect-RsReportServer
7982
[switch]
8083
$RegisterProxy,
8184

85+
[Alias('ApiVersion')]
8286
[ValidateSet('2005','2006','2010')]
8387
[string]
84-
$SoapEndpointApiVersion = '2010'
88+
$SoapEndpointApiVersion = '2010',
89+
90+
[switch]
91+
$CustomAuthentication
8592
)
8693

8794
if ($PSBoundParameters.ContainsKey("ComputerName"))
@@ -106,7 +113,7 @@ function Connect-RsReportServer
106113
[Microsoft.ReportingServicesTools.ConnectionHost]::ReportServerUri = $ReportServerUri
107114
try
108115
{
109-
$proxy = New-RsWebServiceProxy -ReportServerUri ([Microsoft.ReportingServicesTools.ConnectionHost]::ReportServerUri) -Credential ([Microsoft.ReportingServicesTools.ConnectionHost]::Credential) -ApiVersion $SoapEndpointApiVersion -ErrorAction Stop
116+
$proxy = New-RsWebServiceProxyHelper -BoundParameters $PSBoundParameters
110117
[Microsoft.ReportingServicesTools.ConnectionHost]::Proxy = $proxy
111118
}
112119
catch
@@ -115,7 +122,7 @@ function Connect-RsReportServer
115122
}
116123
}
117124

118-
if ($PSBoundParameters.ContainsKey("ReportPortalUri"))
125+
if ($PSBoundParameters.ContainsKey("ReportPortalUri"))
119126
{
120127
[Microsoft.ReportingServicesTools.ConnectionHost]::ReportPortalUri = $ReportPortalUri
121128
}

ReportingServicesTools/Functions/Utilities/New-RsWebServiceProxy.ps1

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ function New-RsWebServiceProxy
2424
By Default, this parameter uses the credentials (if any) specified by the Connect-RsReportingServer function.
2525
2626
.PARAMETER ApiVersion
27-
The version of the API to use, 2010 by default. Sepcifiy '2005' or '2006' if you need
27+
The version of the API to use, 2010 by default. Specify '2005' or '2006' if you need
2828
to query a Sql Server Reporting Service Instance running a version prior to
2929
SQL Server 2008 R2 to access those respective APIs.
30+
31+
.PARAMETER CustomAuthentication
32+
If the server implements a custom authentication schema such as 'Forms' instead of standard Basic/NTLM.
3033
3134
.EXAMPLE
3235
New-RsWebServiceProxy
@@ -60,7 +63,10 @@ function New-RsWebServiceProxy
6063

6164
[ValidateSet('2005','2006','2010')]
6265
[string]
63-
$ApiVersion = '2010'
66+
$ApiVersion = '2010',
67+
68+
[switch]
69+
$CustomAuthentication
6470
)
6571

6672
#region If we did not specify a connection parameter, use a default connection
@@ -102,12 +108,28 @@ function New-RsWebServiceProxy
102108
Write-Verbose "Establishing proxy connection to $ReportServerUri..."
103109
if ($Credential)
104110
{
105-
New-WebServiceProxy -Uri $ReportServerUri -Credential $Credential -ErrorAction Stop
111+
$proxy = New-WebServiceProxy -Uri $ReportServerUri -Credential $Credential -ErrorAction Stop
106112
}
107113
else
108114
{
109-
New-WebServiceProxy -Uri $ReportServerUri -UseDefaultCredential -ErrorAction Stop
115+
$proxy = New-WebServiceProxy -Uri $ReportServerUri -UseDefaultCredential -ErrorAction Stop
116+
}
117+
118+
if ($CustomAuthentication)
119+
{
120+
if (!$Credential)
121+
{
122+
$Credential = Get-Credential
123+
}
124+
$NetworkCredential = $Credential.GetNetworkCredential()
125+
126+
$proxy.CookieContainer = New-Object System.Net.CookieContainer
127+
$proxy.LogonUser($NetworkCredential.UserName, $NetworkCredential.Password, "Forms")
128+
129+
Write-Verbose "Authenticated!"
110130
}
131+
132+
return $proxy
111133
}
112134
catch
113135
{

0 commit comments

Comments
 (0)