Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Services / Reporting Services / June 2006

Tip: Looking for answers? Try searching our database.

WebForms.ReportViewer and ReportServerCredentials property?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Asaf - 24 May 2006 09:40 GMT
Hi,

I have an ASPX web form with a WebForms.ReportViewer on it.

I have created a new ReportServerCredentials class form this site
http://blogs.msdn.com/bimusings/archive/2005/11/18/494436.aspx

My code for the report viewer is:

rvBlackListReport.ProcessingMode = ProcessingMode.Remote;

rvBlackListReport.ServerReport.ReportServerUrl = new
Uri("https://www.MyDomain.com/ReportServer");
       rvBlackListReport.ServerReport.ReportPath = "/MyReports/TestReport";

       ReportViewerCredentials rvc = new
ReportViewerCredentials("TestUser", "TestPassword", "");
       rvBlackListReport.ServerReport.ReportServerCredentials = rvc;

When trying to view the report I am receiving the error:

The request failed with HTTP status 401: Unauthorized.
* same user and password works fine on windows application.

Thanks in advanced for any help,
Asaf
Steven Cheng[MSFT] - 24 May 2006 11:17 GMT
Hello Asaf,

Thank you for posting.

As for the custom "IReportServerCredentials" implementation class, based on
my research, we should use the "NetworkCredentials" property to supply the
credential that will be used for authentication against the remote
reportServer. Here is a test ServerCredential class I used:

public class ReportViewerCredentials : IReportServerCredentials
   {
     

   private string _username;
   private string _password;
   private string _domain;

   public Uri ReportServerUrl;

   public ReportViewerCredentials(string username, string password, string
domain)
   {
       _username = username;
       _password = password;
       _domain = domain;
   }

       #region IReportServerCredentials Members

     ..........................

       public System.Security.Principal.WindowsIdentity ImpersonationUser
       {
           get {

               return null;
           }
       }

       public System.Net.ICredentials NetworkCredentials
       {
           

           get {

               System.Net.NetworkCredential nc = new
NetworkCredential(_username, _password, _domain);
               CredentialCache cc = new CredentialCache();

               cc.Add(ReportServerUrl, "Negotiate", nc);

               return cc;
             
           }
       }

       #endregion
   }
======================================

========test page code=============
protected void Page_Load(object sender, EventArgs e)
   {
     
       ReportViewerCredentials rvc = new
ReportViewerCredentials("TestUser", "Password01!", "machinename");

       rvc.ReportServerUrl = ReportViewer1.ServerReport.ReportServerUrl;

       ReportViewer1.ServerReport.ReportServerCredentials = rvc;

   }
=============================

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================

Signature

This posting is provided "AS IS" with no warranties, and confers no rights.


Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Asaf - 24 May 2006 12:47 GMT
Hello Steven,

I have tried your code but still I am getting the error:
"The request failed with HTTP status 401: Unauthorized"

I have tried also to use administrator user.
Strange that on windows forms app it working with no problems.

Is there something I need to configure at Web.config file?

Regards,
Asaf

> Hello Asaf,
>
[quoted text clipped - 89 lines]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
Steven Cheng[MSFT] - 25 May 2006 06:47 GMT
Thanks for your response Asaf,

"401: Unauthorized" means there is not credential passed to server-side for
authentication or authentication failed. Have you checked the IIS log of
the reportServer application to see what's the log entry for those requests
(from your ASP.NET application). Also, my local test ASP.NET application
doesn't add any particular configuration entry in the web.config file. Just
use the code I provided to attach the ReportServerCredential...

Regards,

Steven Cheng
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================

Signature

This posting is provided "AS IS" with no warranties, and confers no rights.


Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Michael R - 29 Jun 2006 19:14 GMT
Steven - how would you write a class that inherits an interface in VB.NET?  
It seems that when I convert your code to VB I cannot do as you can in
C#...do you have a VB.NET solution?

thanks - Michael R.

Imports Microsoft.Reporting.WebForms

Public Class MyReportServerCredentials
   Inherits IReportServerCredentials  
   'line states that classes can only inherit from other classes.

   Public Sub New()
       MyBase.New()

   End Sub

   Public ReadOnly Property ImpersonationUser() As
System.Security.Principal.WindowsIdentity
       Get
           Return Nothing
           ' Use default identity.
       End Get
   End Property

   Public ReadOnly Property NetworkCredentials() As System.Net.ICredentials
       Get
           Return New System.Net.NetworkCredential("user", "pass", "domain")
       End Get
   End Property

   Public Function GetFormsCredentials(ByRef authCookie As
System.Net.Cookie, ByRef user As String, ByRef password As String, ByRef
authority As String) As Boolean
       authCookie = Nothing
       authority = Nothing
       password = Nothing
       user = Nothing
       Return False
       ' Not use forms credentials to authenticate.
   End Function
End Class

> Hello Asaf,
>
[quoted text clipped - 89 lines]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
Michael R - 29 Jun 2006 19:36 GMT
I think I just found the answer.  See this post, it's in VB.NET:
http://forums.asp.net/thread/1271383.aspx

thanks!

> Steven - how would you write a class that inherits an interface in VB.NET?  
> It seems that when I convert your code to VB I cannot do as you can in
[quoted text clipped - 132 lines]
> > (This posting is provided "AS IS", with no warranties, and confers no
> > rights.)
Jimmy M Joy - 24 May 2006 22:28 GMT
Please go through these links

http://support.microsoft.com/?id=30615
http://www.c-sharpcorner.com/UploadFile/chauhan_sonu57/ProgrammaticImpersonation
02022006080545AM/ProgrammaticImp


ersonation.aspx?ArticleID=3aa21cd6-b867-4306-96ed-de0ba5930fa1
http://blogs.msdn.com/bimusings/archive/2005/11/18/494436.aspx

Reagards,
Jimmy M Joy
Signature

Microsoft Application Developer

> Hi,
>
[quoted text clipped - 22 lines]
> Thanks in advanced for any help,
> Asaf
Asaf - 25 May 2006 08:10 GMT
Hello Jimmy,

I have tried all the links but still getting HTTP Error: 401.

Regards,
Asaf

> Please go through these links
>
[quoted text clipped - 33 lines]
> > Thanks in advanced for any help,
> > Asaf
Steven Cheng[MSFT] - 26 May 2006 07:45 GMT
Hi Asaf,

Have you checked the reportServer application's IIS log to see whether it
provide any clues. Also, in my local test envrionment, my reportserver is
installed on the default IIS site with integrated windows authentication
(anonymous denied), and I'm correctly use the webform ReportViewer control
and the custom credential class I posted to access the reportServer. Also,
is it possible that the supplied account's username/password is incorrect
or doesn't meet the requirement(I tested use local accounts on the server
machines and even when authenticated failed, the reportViewer control will
inform me the account name which is denied for accessing the target
report). Have you tried it on any other machine?

Regards,

Steven Cheng
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================

Signature

This posting is provided "AS IS" with no warranties, and confers no rights.


Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Asaf - 26 May 2006 11:36 GMT
Hello Steven,

I have called Microsoft support regarding this issue and this is what a
Microsoft representative sent to my Email as I understood there is a bug here.

"Thank you for contacting Microsoft Online Support Service. My name is… and
I will be assisting you with this service request.
We found that there is a problem in using the case number… and it was caused
by an issue in our case creation system we have taken actions to fix it."

Regards,
Asaf

> Hi Asaf,
>
[quoted text clipped - 26 lines]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
Steven Cheng[MSFT] - 29 May 2006 02:29 GMT
Thanks for your followup Asaf,

Seems the error message is regarding on the case number association.
Anyway, during he sametime, I think you can still try those things I
mentioned in the previous message and inform the CSSsupport engineer on
this.

Regards,

Steven Cheng
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================

Signature

This posting is provided "AS IS" with no warranties, and confers no rights.


Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.