When you try to access a report server web service to execute code you get an error similar to, where the scheme or header varies a tiny bit
The HTTP request is unauthorized with client authentication scheme ‘Basic’. The authentication header received from the server was ‘Negotiate,NTLM
Basically my situation is that we have a MS 2008 Server running SSRS outside of our domain in the DMZ. However we need to execute code on a domain machine that will connect and run over 100 reports on the SSRS Server, then dump them on a share in our domain in excel format.
To get around the negotiation problem you need to make sure the SSRS server is allowing connections configured using basic authentication
Find the file
rsreportserver.config
This is usually buried in the install folder
C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer
Then change the authentication to support your desired connection authentication type
1 2 3 4 5 6 |
<Authentication> <AuthenticationTypes> <RSWindowsBasic/> <RSWindowsNegotiate/> <RSWindowsNTLM/> </AuthenticationTypes> |
More info at MSDN
Once you have done that you should be good to connect.
Here is some sample code to get you started with connecting to your web service and pulling back a list of items
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
Imports System Imports TestExecuteSSRS.SSRS1510 Imports System.IO Imports System.Text Imports System.Web.Services.Protocols Imports System.Xml Imports System.Xml.Serialization Imports System.ServiceModel Imports rs = TestExecuteSSRS.SSRS1510 Module module1 Sub Main(ByVal args As String()) 'Dim service = New rs.ReportingService2010SoapClient() Dim binding = New BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly) Dim endpointUri = "http://<ipaddress>/reportserver/ReportService2010.asmx" 'binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows 'OR binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic Dim service = New rs.ReportingService2010SoapClient(binding, New EndpointAddress(endpointUri)) 'service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation 'OR service.ClientCredentials.UserName.UserName = "<machinename>\<username>" service.ClientCredentials.UserName.Password = "<password>" ' Retrieve a list of reports. Dim reports As rs.CatalogItem() = Nothing service.ListChildren(New rs.TrustedUserHeader(), "/<Target Folder>", True, reports) For Each report As CatalogItem In reports Console.WriteLine("{0} ({1}) : {2}", report.Name, report.Path, report.TypeName) If report.TypeName = "Report" Then 'run the report and save it as excel End If Next End Sub End Module |