<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>RedSouljaz Blog &#187; Reporting Services</title>
	<atom:link href="http://redsouljaz.com/category/programming/reporting-services/feed/" rel="self" type="application/rss+xml" />
	<link>http://redsouljaz.com</link>
	<description>My Personal Blog&#039;s</description>
	<lastBuildDate>Mon, 25 Apr 2011 09:17:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ask for username and password when calling reporting service</title>
		<link>http://redsouljaz.com/2010/06/22/ask-for-username-and-password-when-calling-reporting-service/</link>
		<comments>http://redsouljaz.com/2010/06/22/ask-for-username-and-password-when-calling-reporting-service/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 03:42:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[Ask for username and password]]></category>
		<category><![CDATA[Ask for username and password when calling reporting service]]></category>
		<category><![CDATA[GetFormsCredentials]]></category>
		<category><![CDATA[how to set credentials for reporting services]]></category>
		<category><![CDATA[keep asking for username and password when calling reporting services]]></category>
		<category><![CDATA[NetworkCredentials]]></category>
		<category><![CDATA[pop up authentication when calling reporting service]]></category>
		<category><![CDATA[reporting service]]></category>

		<guid isPermaLink="false">http://redsouljaz.com/?p=335</guid>
		<description><![CDATA[These code allow us to set username and password for reporting services to avoid popup request authentication.
This code tested in Visual Studio 2008 and Reporting Services from SQL Server 2005
First create a class called ReportServerCredentials.vb

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

Public NotInheritable Class ReportServerCredentials
    Implements IReportServerCredentials

    Public ReadOnly Property ImpersonationUser() As WindowsIdentity [...]]]></description>
			<content:encoded><![CDATA[<p>These code allow us to set username and password for reporting services to avoid popup request authentication.</p>
<p>This code tested in Visual Studio 2008 and Reporting Services from SQL Server 2005</p>
<p>First create a class called ReportServerCredentials.vb</p>
<pre class="brush: vb;">
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
        Get

            '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
        Get

            '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 = _
                ConfigurationManager.AppSettings(&quot;UserName&quot;)

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

            'Password
            Dim password As String = _
                ConfigurationManager.AppSettings(&quot;Password&quot;)

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

            'Domain
            Dim domain As String = _
                ConfigurationManager.AppSettings(&quot;SERVERNAME&quot;)

            If (String.IsNullOrEmpty(domain)) Then
                Throw New Exception(&quot;Missing domain from web.config file&quot;)
            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 
</pre>
<p>Second, add parameter key to your web.config</p>
<pre class="brush: vb;">
&lt;appSettings&gt;
&lt;add key=&quot;UserName&quot; value=&quot;UserName&quot;/&gt;
		&lt;add key=&quot;Password&quot; value=&quot;Password&quot;/&gt;
		&lt;add key=&quot;SERVERNAME&quot; value=&quot;SERVERNAME&quot;/&gt;
&lt;/appSettings&gt;
</pre>
<p>And then add this line of code before calling reportserverURL in the report view page:</p>
<pre class="brush: vb;">
ReportViewer1.ServerReport.ReportServerCredentials = New ReportServerCredentials()
</pre>
]]></content:encoded>
			<wfw:commentRss>http://redsouljaz.com/2010/06/22/ask-for-username-and-password-when-calling-reporting-service/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

