Authorization ticket not received by LogonUser
Hi,I am trying to get the Forms Authentication sample code working for SSRS 2008. I can't seem to get the cookie management to work correctly. In the GetWebResponse method, the webResponse.Cookies collection is always 0, so I always get the exception "Authorization ticket not received by LogonUser". Before the GetWebResponse method is called, the GetWebRequest method is called. This tries to add a cookie to the request cookie container but it is always null so it never gets added. Can someone please tell me how this is supposed to work? 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 CookieContainer(); request.CookieContainer = cookieJar; <strong><span style="text-decoration:underline">Cookie authCookie = AuthCookie;</span></strong> // 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; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes")] 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; <strong><span style="text-decoration:underline">Cookie authCookie = webResponse.Cookies[cookieName]; // If the auth cookie is null, throw an exception if (authCookie == null) { throw new Exception( "Authorization ticket not received by LogonUser"); }</span></strong> // otherwise save it for this request AuthCookie = authCookie; // and send it to the client Utilities.RelayCookieToClient(authCookie); } return response; } private Cookie AuthCookie { get { if (m_Authcookie == null) m_Authcookie = Utilities.TranslateCookie( HttpContext.Current.Request.Cookies[Utilities.CustomAuthCookieName]); return m_Authcookie; } set { m_Authcookie = value; } } private Cookie m_Authcookie = null; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")] internal sealed class Utilities { internal static string CustomAuthCookieName { get { lock (m_cookieNamelockRoot) { return m_cookieName; } } set { lock (m_cookieNamelockRoot) { m_cookieName = value; } } } private static string m_cookieName; private static object m_cookieNamelockRoot = new object(); private static HttpCookie TranslateCookie(Cookie netCookie) { if (netCookie == null) return null; HttpCookie webCookie = new HttpCookie(netCookie.Name, netCookie.Value); // Add domain only if it is dotted - IE doesn't send back the cookie // if we set the domain otherwise if (netCookie.Domain.IndexOf('.') != -1) webCookie.Domain = netCookie.Domain; webCookie.Expires = netCookie.Expires; webCookie.Path = netCookie.Path; webCookie.Secure = netCookie.Secure; return webCookie; } internal static Cookie TranslateCookie(HttpCookie webCookie) { if (webCookie == null) return null; Cookie netCookie = new Cookie(webCookie.Name, webCookie.Value); if (webCookie.Domain == null) netCookie.Domain = HttpContext.Current.Request.ServerVariables["SERVER_NAME"]; netCookie.Expires = webCookie.Expires; netCookie.Path = webCookie.Path; netCookie.Secure = webCookie.Secure; return netCookie; } Thanks,~Corey
August 11th, 2009 4:44pm

I m having same issue ....
Free Windows Admin Tool Kit Click here and download it now
November 11th, 2011 11:23am

I resolved this issue now. Change this class AuthenticationUtilities class - change it from 2010 to 2005 // private const string wmiNamespace = @"\root\Microsoft\SqlServer\ReportServer\{0}\v10"; private const string wmiNamespace = @"\root\Microsoft\SqlServer\ReportServer\RS_{0}\v10"; // private const string rsAsmx = @"/ReportService2010.asmx"; private const string rsAsmx = @"/ReportService2005.asmx";
November 11th, 2011 4:52pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics