Visual Studio Development Bookmark and Share   
 index > Visual Studio Report Controls > reportViewer.ServerReport.ReportServerCredentials.NetworkCredentials readonly
 

reportViewer.ServerReport.ReportServerCredentials.NetworkCredentials readonly

I am trying to call a report in a reportviewer control (asp.net) using basic authentication. To achieve this I have the following code

Dim reportViewer As New ReportViewer()

reportViewer.ServerReport.ReportServerCredentials.NetworkCredentials = New NetworkCredential("user", "pwd", "domain")

However I keep getting NetworkCredentials is readonly, why is this??

Maddog C  Wednesday, August 16, 2006 11:05 AM

well , you should implement IReportServerCredential, and code example as follow :

public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials
{

// local variable fornetwork credential.
private string _UserName;
private string _PassWord;
private string _DomainName;
public CustomReportCredentials(string UserName, string PassWord, string DomainName)
{
_UserName = UserName;
_PassWord = PassWord;
_DomainName = DomainName;
}
public WindowsIdentity ImpersonationUser
{
get
{
return null; // not use ImpersonationUser
}
}
public ICredentials NetworkCredentials
{
get
{

// use NetworkCredentials
return new NetworkCredential(_UserName,_PassWord,_DomainName);
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
{

// not use FormsCredentials unless you have implements acustom autentication.
authCookie = null;
user = password = authority = null;
return false;
}

}

then use this as follows:

IReportServerCredentials irsc = new CustomReportCredentials(userid,password, domain);
ReportViewer1.ServerReport.ReportServerCredentials = irsc;

the other code to set ServerReport property omit. hope you have a good day.

lilypark  Thursday, August 17, 2006 2:31 AM

well , you should implement IReportServerCredential, and code example as follow :

public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials
{

// local variable fornetwork credential.
private string _UserName;
private string _PassWord;
private string _DomainName;
public CustomReportCredentials(string UserName, string PassWord, string DomainName)
{
_UserName = UserName;
_PassWord = PassWord;
_DomainName = DomainName;
}
public WindowsIdentity ImpersonationUser
{
get
{
return null; // not use ImpersonationUser
}
}
public ICredentials NetworkCredentials
{
get
{

// use NetworkCredentials
return new NetworkCredential(_UserName,_PassWord,_DomainName);
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
{

// not use FormsCredentials unless you have implements acustom autentication.
authCookie = null;
user = password = authority = null;
return false;
}

}

then use this as follows:

IReportServerCredentials irsc = new CustomReportCredentials(userid,password, domain);
ReportViewer1.ServerReport.ReportServerCredentials = irsc;

the other code to set ServerReport property omit. hope you have a good day.

lilypark  Thursday, August 17, 2006 2:31 AM
That doesn't change anything... it's still READ ONLY!
GunnSgtHartman  Wednesday, June 18, 2008 11:37 PM
GunnSgtHartman said:

That doesn't change anything... it's still READ ONLY!


The example code does work. Notice he is setting:

ReportViewer1.ServerReport.ReportServerCredentials

NOT

reportViewer.ServerReport.ReportServerCredentials.NetworkCredentials
ADefwebserver  Sunday, November 23, 2008 5:09 PM

You can use google to search for other answers

Custom Search

More Threads

• FireFox Compatiblity
• Does local report require admin privs on server?
• Search the records after the records populated.
• System.OutOfMemoryException
• Report Viewer wait message position
• Problem with ActiveX control in RS Report Viewer Control(Urgent)
• Does ReportViewer cache results?
• multiple reports
• report viewer textbox keep together problem
• Spacing between bar graphs