Reporting Services 2008: asking for username and password

A co-worker was developing some reports and embedding them on an ASP.Net webpage using Reporting Services 2005. Everything was working OK.

However, when I had to put the webapp into the production server, it was always prompting for username/password.

The production server is a Windows 2008 server, having Reporting Services 2008.

As you may know, Reporting Services 2008 doesn’t use IIS to provide access to the ReportManager or ReportServer, so you can’t use anonymous login.

So, in this sense it’s a bit more secure than Reporting Services 2005. But it’s harder to deploy.

The username/password it’s asking for is the Windows username/password.

I would never reveal this to final users so I looked for a solution.

I came to this page and found the solution:

Basically, you have to store username/password on AppSettings section on your web.config and create a class on App_Code to read these network credentials so Reporting Services don’t ask users for Windows username/password.

On your web.config:

<add key="UserName" value="UserName"/>
                <add key="Password" value="Password"/>
                <add key="SERVERNAME" value="SERVERNAME"/>


The class ReportServerCredentials is:


Imports Microsoft.VisualBasic
Imports Microsoft.Reporting.WebForms
Imports System.Security.Principal

Public NotInheritable Class ReportServerCredentials
    Implements IReportServerCredentials

    Public ReadOnly Property ImpersonationUser() As WindowsIdentity _
            Implements IReportServerCredentials.ImpersonationUser

            'Use the default windows user.  Credentials will be
            'provided by the NetworkCredentials property.
            Return Nothing

        End Get
    End Property

    Public ReadOnly Property NetworkCredentials() As Net.ICredentials _
            Implements IReportServerCredentials.NetworkCredentials

            'Read the user information from the web.config file.  
            'By reading the information on demand instead of storing
            'it, the credentials will not be stored in session,
            'reducing the vulnerable surface area to the web.config
            'file, which can be secured with an ACL.

            'User name
            Dim userName As String = _

            If (String.IsNullOrEmpty(userName)) Then
                Throw New Exception("Missing user name from web.config file")
            End If

            Dim password As String = _

            If (String.IsNullOrEmpty(password)) Then
                Throw New Exception("Missing password from web.config file")
            End If

            Dim domain As String = _

            If (String.IsNullOrEmpty(domain)) Then
                Throw New Exception("Missing domain from web.config file")
            End If

            Return New Net.NetworkCredential(userName, password, domain)

        End Get
    End Property

    Public Function GetFormsCredentials(ByRef authCookie As System.Net.Cookie, _
                                        ByRef userName As String, _
                                        ByRef password As String, _
                                        ByRef authority As String) _
                                        As Boolean _
            Implements IReportServerCredentials.GetFormsCredentials

        authCookie = Nothing
        userName = Nothing
        password = Nothing
        authority = Nothing

        'Not using form credentials
        Return False

    End Function

End Class


Then, you can call your Report the following way:


            reportViewer.ProcessingMode = ProcessingMode.Remote
            Dim serverReport As ServerReport
            serverReport = reportViewer.ServerReport
            'Set the report server URL and report path
            serverReport.ReportServerUrl = _
                New Uri("")
                serverReport.ReportPath = _
            'Read network credentials from your web.config using ReportServerCredentials class on App_Code
            serverReport.ReportServerCredentials = New ReportServerCredentials()
            'Create the sales order number report parameter
            Dim P_IDPERSONAL As New ReportParameter()
            P_IDPERSONAL.Name = "P_IDPERSONAL"

            'Set the report parameters for the report
            Dim parameters() As ReportParameter = {P_IDPERSONAL}



One response to this post.

  1. No creia leer uuո post asi en este blog ,en caambio hoy estoy realmente satisfecho con
    el de hoy



Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s

A %d blogueros les gusta esto: