locked
The request failed with HTTP status 401: Unauthorized. RRS feed

  • Question

  • We are using SQL Server Reporting Services 2008 R2 with much success.

    I just created a report which performs properly when run from Reporting Services.

    When trying to execute it from a vb.net desktop app the following error is thrown:

    The request failed with HTTP status 401: Unauthorized.

    The code that throws the error is:        execInfo = WebReference1.LoadReport(reportPath, historyID)

    Any information to help resolve this will be greatly appreciated.

    Thanks in advance!

    Wednesday, July 25, 2012 1:41 PM

Answers

  • Hello ss-Man,

    Thanks for your response.

    The credential is composed of domain, user name, and password. If the application is a desktop application, then System.Net.CredentialCache.DefaultNetworkCredentials will pass the current logon users domain account to the server. Actually, the expected credential can pass the authentication on the reporting service. In another word, the credential allow the user to log onto the server. Please try to pass the valid authentication again to see whether it works or not.

    Here is a way to pass the custom authentication instead of the credential from the CredentialCache.

    http://msdn.microsoft.com/en-us/library/ms254287(v=vs.100)

    I hope it is helpful to you.

    Regards,

    Edward


    Edward Zhu

    TechNet Community Support

    • Proposed as answer by Edward Zhu Monday, July 30, 2012 6:11 AM
    • Marked as answer by Edward Zhu Thursday, August 2, 2012 2:01 AM
    Friday, July 27, 2012 7:10 AM
  • Edward,

        The credentials are working properly.

        When attempting to access the ReportService2005 Webservice the generated code was using the computername where the webservice resided rather than our IP address.  When I replaced the computername with the IP the methods for ReportService2005 were than exposed and I could access the subscriptions for our reports.

        Thank You,

    Steve

    • Marked as answer by ss-Man Friday, August 3, 2012 8:15 PM
    Friday, August 3, 2012 8:14 PM

All replies

  • Hello

    Recently, I got this issue with Integrated mode. I have deleted all Data Sources, reports and re-deployed all. Please provide Admin permissions to the reports authentication at data source for testing.

    It may help you

    http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/50179ac7-9775-436a-a4ae-79b777e0ef24

    Let me know your testing/results

    Thanks


    Prav

    Wednesday, July 25, 2012 3:14 PM
  • Prav,

    Thanks for getting back to me.

    Unfortunately, the app is still throwing Web Exception: The request failed with HTTP status 401: Unauthorized.

    The following was tried:
      confirmed administrative privledges on server(SQL Server Reporting Services)
      created a new test folder "Test" on SSRS server
      redeployed report into "Test" folder after modifying data source credentials to administrator
      successfully tested report from "Test" folder

    but

    when report is run from desktop app. the following error is thrown:

    The request failed with HTTP status 401: Unauthorized.

    The code that throws the error is: execInfo = WebReference1.LoadReport(reportPath, historyID)

    Additional Notes:

    If the report from SSRS runs successfully(which it does)
    and does not from my VB app.

    then

    What Webreference1.Credentials(for this report) should I be using?
    And where can I find those credentials on the SSRS server?


    For example, do I need to set or get credentials from the Reportexecution2005.asmx file which is used in the Web reference URL?
    • Edited by ss-Man Wednesday, July 25, 2012 9:12 PM
    Wednesday, July 25, 2012 7:34 PM
  • Hello ss-Man,

    Thank you to post your question on TechNet forum.

    It is necessary to assign the credential information to the report. In your VB.net code, please try to use the following code to assign the credential to the ReportExecution2005 service before you call LoadReport function.

    WebReference1.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials

    It will pass the current Windows user's credential to the service. If the current user has the permission to access the reporting service, it will solve 401 issue. I hope it is helpful to you. If you have any questions about this issue, please let me know.

    Regards,

    Edward


    Edward Zhu

    TechNet Community Support

    Thursday, July 26, 2012 7:21 AM
  • Edward,

    Thanks for the response!

    Replaced code: WebReference1.Credentials = System.Net.CredentialCache.DefaultCredentials

    with: WebReference1.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials

    Unfortunately this still yields Web Exception: The request failed with HTTP status 401: Unauthorized.


    Notes:

    The credentials appear to be the issue.
    What are the credentials composed of?
    Is it username and password or something else?
    What credentials are reporting services looking for and where can they be found?

    Regards,

    Thursday, July 26, 2012 12:58 PM
  • Hello ss-Man,

    Thanks for your response.

    The credential is composed of domain, user name, and password. If the application is a desktop application, then System.Net.CredentialCache.DefaultNetworkCredentials will pass the current logon users domain account to the server. Actually, the expected credential can pass the authentication on the reporting service. In another word, the credential allow the user to log onto the server. Please try to pass the valid authentication again to see whether it works or not.

    Here is a way to pass the custom authentication instead of the credential from the CredentialCache.

    http://msdn.microsoft.com/en-us/library/ms254287(v=vs.100)

    I hope it is helpful to you.

    Regards,

    Edward


    Edward Zhu

    TechNet Community Support

    • Proposed as answer by Edward Zhu Monday, July 30, 2012 6:11 AM
    • Marked as answer by Edward Zhu Thursday, August 2, 2012 2:01 AM
    Friday, July 27, 2012 7:10 AM
  • Edward,

        I have been working on other issues. 

        Thanks for your patience.

    • Marked as answer by ss-Man Friday, August 3, 2012 8:07 PM
    • Unmarked as answer by ss-Man Friday, August 3, 2012 8:14 PM
    Monday, July 30, 2012 8:33 PM
  • Edward,

        The credentials are working properly.

        When attempting to access the ReportService2005 Webservice the generated code was using the computername where the webservice resided rather than our IP address.  When I replaced the computername with the IP the methods for ReportService2005 were than exposed and I could access the subscriptions for our reports.

        Thank You,

    Steve

    • Marked as answer by ss-Man Friday, August 3, 2012 8:15 PM
    Friday, August 3, 2012 8:14 PM