locked
Logon failed error with reporting services RRS feed

  • Question

  • User-1522740346 posted

    Hi ,

    I am logged into my web app with credentials successfully and when i view the reports first time they open successfully.

    Now the logged in user can also act on behalf of another user by submitting the login on the page.

    But this time when i access the reports it says login failed..even though i am passing the same credentials of the original user who is already authenticated.

    Could you please help with this.

    Below is the code

            protected override WebRequest GetWebRequest(Uri uri)
            {
                HttpWebRequest request;

                request = (HttpWebRequest)HttpWebRequest.Create(uri);

                // Create a cookie jar to hold the request cookie
                CookieContainer cookieJar = new System.Net.CookieContainer();
                request.CookieContainer = cookieJar;

                foreach (string cookieName in HttpContext.Current.Request.Cookies.AllKeys)
                    request.CookieContainer.Add(Utilities.TranslateCookie(HttpContext.Current.Request.Cookies[cookieName]));

                Cookie authCookie = AuthCookie;

                // if the client already has an auth cookie
                // place it in the request's cookie container
                if (authCookie != null)
                    request.CookieContainer.Add(authCookie);

                request.Timeout = -1;
                request.Headers.Add("Accept-Language", HttpContext.Current.Request.Headers["Accept-Language"]);

                return request;
            }

            protected override WebResponse GetWebResponse(WebRequest request)
            {
                WebResponse response = base.GetWebResponse(request);

                string cookieName = response.Headers["RSAuthenticationHeader"];

                // If the response contains an auth header, store the cookie
                if (cookieName != null)
                {
                    Utilities.CustomAuthCookieName = cookieName;
                    HttpWebResponse webResponse = (HttpWebResponse)response;
                    Cookie authCookie = webResponse.Cookies[cookieName];

                    // If the auth cookie is null, throw an exception
                    if (authCookie == null)
                        throw new FrameworkException("Authorization ticket not received by LogonUser");

                    // otherwise save it for this request
                    AuthCookie = authCookie;

                    // and send it to the client
                    Utilities.RelayCookieToClient(authCookie);
                }

                return response;
            }

    Tuesday, March 6, 2012 11:31 PM

Answers

  • User2105670541 posted

    well i would recomend you to use

    <Identity Impersonate ="true" username="ReportUser" password="somePassword">

    in web.config file of your application, the ReportUser should be the local user in your ReportServer(and should have access to view browser reports) and also the same user with same credentials needs to be there in your server where your  web application is hosted. after doing this i dont think you will need to create those Token and all. Try it I'm sure it will work.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 7, 2012 2:13 AM

All replies

  • User-1522740346 posted

    HI,

    I saw that second time when i try to access the report. there is not header present in the response and is failing below.

    string cookieName = response.Headers["RSAuthenticationHeader"];

    Tuesday, March 6, 2012 11:34 PM
  • User2105670541 posted

    well i would recomend you to use

    <Identity Impersonate ="true" username="ReportUser" password="somePassword">

    in web.config file of your application, the ReportUser should be the local user in your ReportServer(and should have access to view browser reports) and also the same user with same credentials needs to be there in your server where your  web application is hosted. after doing this i dont think you will need to create those Token and all. Try it I'm sure it will work.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 7, 2012 2:13 AM
  • User1690324985 posted

    Hello,

    Can you provide the exact error message you are getting?

    Wednesday, March 7, 2012 2:23 AM