Groups | Blog | Home
all groups > sql server reporting services > august 2005 >

sql server reporting services : HTTP 401 - Unauthorized


Mark_Rarefy
8/29/2005 8:27:45 AM
Windows 2003 SP1
SQL 2000 SP4
RS SP2

I have a soap call to the report server that would generate a PDF. After
installing SP1 to windows 2003 my code stopped working. I would get HTTP 401
- Unauthorized. If I remove SP1 code works like a champ.

I have done the DisableLoopbackCheck = 1 as discribed in the below KB
http://support.microsoft.com/default.aspx?scid=kb;en-us;896861
But the issue lives on.

Here is the code.
<code>
Dim rs As New srvReportServer.ReportingService
rs.Credentials = New
NetworkCredential(ConfigurationSettings.AppSettings("RSUserName"),
ConfigurationSettings.AppSettings("RSPassword"),
ConfigurationSettings.AppSettings("RSDomain"))
'rs.Credentials = System.Net.CredentialCache.DefaultCredentials

' Rendered HTML page content.
Dim abytContent As Byte() = Nothing

' Web root for the application. URL image references in the
' HTML emitted by Reporting Services will be prefixed with this.
Dim strStreamRoot As String = "/path"

'Dim strFormat As String = "HTML4.0"
'Dim strFormat As String = "MHTML"
'Dim strFormat As String = "EXCEL"
Dim strFormat As String = "PDF"
'Dim strFormat As String = "XML"
'Dim strFormat As String = "CSV"
'Dim strFormat As String = "IMAGE"
Dim strHistoryId As String = Nothing
Dim strDeviceInfo As String = _
"<DeviceInfo>" & _
"<HTMLFragment>True</HTMLFragment>" & _
"<Toolbar>False</Toolbar>" & _
"<StreamRoot>" & strStreamRoot & "/images/" &
"</StreamRoot>" & _
"</DeviceInfo>"

Dim aParameter() As srvReportServer.ParameterValue
''Check For Variables
If Request.QueryString("Variables") <> "" Then
Dim astrTemp() As String
''Varialbles will be delimited with a ~ and inside the pair a *
astrTemp = Request.QueryString("Variables").Split("~")
Dim astrVariabkes(astrTemp.GetUpperBound(0), 1) As String
Dim intX As Integer
ReDim aParameter(astrTemp.GetUpperBound(0))
For intX = 0 To astrTemp.GetUpperBound(0)
Dim astrTemp2() As String
astrTemp2 = astrTemp(intX).Split("*")
' Report parameters.
aParameter(intX) = New srvReportServer.ParameterValue
aParameter(intX).Name = astrTemp2(0)
aParameter(intX).Value = astrTemp2(1)
Next
End If

Dim strReportSource As String = Nothing
Dim aCredential As srvReportServer.DataSourceCredentials() = Nothing
Dim strShowHideToggle As String = Nothing
Dim strEncoding As String
Dim strMimeType As String
Dim aWarning As srvReportServer.Warning() = Nothing
Dim aHistoryParameter As srvReportServer.ParameterValue() = Nothing
Dim astrStreamId As String() = Nothing
Dim sh As New srvReportServer.SessionHeader
rs.SessionHeaderValue = sh
strReportSource = Request.QueryString("Path")
Try
' Get the HTML content of the report.
abytContent = rs.Render(strReportSource, strFormat,
strHistoryId, strDeviceInfo, aParameter, aCredential, strShowHideToggle,
strEncoding, strMimeType, aHistoryParameter, aWarning, astrStreamId)
sh.SessionId = rs.SessionHeaderValue.SessionId
Console.WriteLine("(Render) SessionId: {0}",
rs.SessionHeaderValue.SessionId)

Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.BinaryWrite(abytContent)
Catch e As SoapException
Logger.Write(e, "Error", 3)
End Try

' Write report content.
Page.Response.BinaryWrite(abytContent)
Jason Rodman
9/7/2005 3:41:02 PM
I am having the same exact problem. Any ideas guys?

[quoted text, click to view]
AddThis Social Bookmark Button