I'm using ReportViewer for connecting to report server. Windows authenticaton works well.. but when I used credentials to authenticate to report server I got the error:
The request failed with HTTP status 401: Unauthorized.
I know I need to configure the report server to accept those credentials, but I don't know actually what it is. Yes I have gone through msdn as well as stack questions too. I'm a complete beginner to SSRS and I want to integrate report server into my web application. what I have done in my application page is:
protected void Page_Load(object sender, EventArgs e)
{
// if (!IsPostBack)
// {
ReportViewer1.ServerReport.ReportServerCredentials =
new MyReportServerCredentials();
// ReportViewer1.ServerReport.Refresh();
//}
}
}
[Serializable]
public sealed class MyReportServerCredentials : IReportServerCredentials
{
public WindowsIdentity ImpersonationUser
{
get
{
// Use the default Windows user. Credentials will be
// provided by the NetworkCredentials property.
return null;
}
}
public ICredentials 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
string userName =
ConfigurationManager.AppSettings
["MyReportViewerUser"];
if (string.IsNullOrEmpty(userName))
throw new Exception(
"Missing user name from web.config file");
// Password
string password =
ConfigurationManager.AppSettings
["MyReportViewerPassword"];
if (string.IsNullOrEmpty(password))
throw new Exception(
"Missing password from web.config file");
// Domain
string domain =
ConfigurationManager.AppSettings
["MyReportViewerDomain"];
if (string.IsNullOrEmpty(domain))
throw new Exception(
"Missing domain from web.config file");
return new NetworkCredential(userName, password, domain);
}
}
public bool GetFormsCredentials(out Cookie authCookie,
out string userName, out string password,
out string authority)
{
// not use FormsCredentials unless you have implements a custom autentication.
authCookie = null;
userName = null;
password = null;
authority = null;
// Not using form credentials
return false;
}
}
And in the RsReportServer.config
file I modified and replaced the <authentication>
node with:
<Authentication>
<AuthenticationTypes>
<Custom />
</AuthenticationTypes>
<EnableAuthPersistence>true</EnableAuthPersistence>
</Authentication>
And in web.config
file of reportserver I changed authentication to forms and impersonate to false, and I did the same in web.config
file of reportmanager .
Anything missing. or am I right?
I also guess I need to do something with CustomSecurity Extension term?