0
votes

---------- Background------------------
I am currently trying to build a webinterface within our intranet for our employees. I would like to build something along the lies of this , were they will be able to access the reports for which they have access to, and some applications that we are working on building that manage different processes based on the departments.

We have an application server and a reporting services server (SQL 2008).

---------- What I've done so far --------------------

I have added a web reference to http://prodrpt/ReportServer/reportservice2005.asmx and I am able to both see the list of services and access them through internet explorer(when I navigate directly to them)

The Web Config uses Authentication mode: Windows Identity Impersonate = true

--------------Problem ----------------------------------

The problem comes when I try and pass the user credentials like this

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim res As String = "---"

    Dim rs As New ReportingService2005()

    rs.Credentials = System.Net.CredentialCache.DefaultCredentials
    Dim items As New prodrpt.CatalogItem()

    For Each item In rs.ListChildren("/", True)
        res = res + item.Name + " | " + item.Path + " | " + item.Type.ToString + "<br />"
    Next
    Response.Write(res)

    cont.InnerHtml = res
End Sub

That Returns this error

The request failed with HTTP status 401: Unauthorized.

Line 925:        [return: System.Xml.Serialization.XmlArrayAttribute("CatalogItems")]
Line 926:        public CatalogItem[] ListChildren(string Item, bool Recursive) {
Line 927:            object[] results = this.Invoke("ListChildren", new object[] {
Line 928:                        Item,
Line 929:                        Recursive});


[WebException: The request failed with HTTP status 401: Unauthorized.]
   System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +412782
   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +300
   prodrpt.ReportingService2005.ListChildren(String Item, Boolean Recursive) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\e22c2559\92c7e946\App_WebReferences.nrvcuhh0.1.cs:927
   apps_Payroll_Main.Page_Load(Object sender, EventArgs e) in C:\inetpub\wwwroot\apps\Payroll\Main.aspx.vb:16
   System.Web.UI.Control.OnLoad(EventArgs e) +132
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428

If I replace rs.Credentials = System.Net.CredentialCache.DefaultCredentials

With

rs.Credentials = New System.Net.NetworkCredential("username", "password")

By passing my credentials directly it works, but I want it to pick out the credentials automatically.

I also noticed that if I enter my credentials like "DOMAIN\username" it fails, but if I just do "username" without the domain it works.

I don't know what to try at this point and any help will be greatly appreciated.

Thank you.

1

1 Answers

1
votes

Do you get the Unauthorized message if you run your site on IIS? Does it work when running the application on the built-in Development Server? If you get the error only on IIS, I guess you have to set the app pool identity to a domain user that has rights to access the web service.