Ejemplo n.º 1
0
        public static string OutputFormsAuthenticationCookie(HttpRequest request)
        {
            string sRet        = "";
            string sCookieName = FormsAuthentication.FormsCookieName;

            DebugOutputHelper.TracedLine("  sCookieName=" + sCookieName);
            HttpCookie c = request.Cookies[sCookieName];

            if (c != null) // && c.HasKeys the cookie exists!
            {
                string cookie = "";
                try
                {
                    cookie = HttpContext.Current.Server.UrlDecode(c.Value);
                    FormsAuthenticationTicket fat = FormsAuthentication.Decrypt(cookie);
                    //TODO extend fat
                    sRet = String.Format("FormsAuthenticationTicket for CookieName={0} is:{1}\n", sCookieName,
                                         FormsAuthenticationTicketAsString(fat, ""));
                }
                catch
                {
                    sRet = String.Format("Unable to retrieve FormsAuthenticationTicket from cookie. FormsCookieName={0} cookie={1}\n", sCookieName, cookie);
                }
            }
            else
            {
                sRet  = String.Format("No FormsAuthentication Cookie found. FormsCookieName={0}\n", sCookieName);
                sRet += TraceOutputHelper.CookieCollectionAsString(request.Cookies, "all cookies");;
            }
            return(sRet);
        }
Ejemplo n.º 2
0
        public static void PrintAspNetIdentities()
        {
#if NET461
            bool bHttpContextAvailable = (System.Web.HttpContext.Current != null);
            if (bHttpContextAvailable)
            {
                Debug.WriteLine("HttpContext.Current.User="******"HttpContext.Current is not available");
            }
            Debug.WriteLine("WindowsIdentity.GetCurrent()=" + System.Security.Principal.WindowsIdentity.GetCurrent().Name);
            Debug.WriteLine("Thread.CurrentPrincipal =" + System.Threading.Thread.CurrentPrincipal.Identity.Name);
            string AuthenticationType = System.Security.Principal.WindowsIdentity.GetCurrent().AuthenticationType;
            Debug.WriteLine("		AuthenticationType			="+ AuthenticationType);
            if (bHttpContextAvailable)
            {
                NameValueCollection serverVariables = System.Web.HttpContext.Current.Request.ServerVariables;
                Debug.WriteLine("serverVariables[LOGON_USER]=" + serverVariables["LOGON_USER"]);
                Debug.WriteLine("serverVariables[AUTH_USER]=" + serverVariables["AUTH_USER"]);
                Debug.WriteLine("serverVariables[REMOTE_USER]=" + serverVariables["REMOTE_USER"]);
            }
#else
            DebugOutputHelper.TracedLine("Not Supported on NETStandard  ");
#endif // NET461
        }
Ejemplo n.º 3
0
 public static void PrintCookies(Uri uri, CookieContainer container)
 {
     if (container == null)
     {
         DebugOutputHelper.TracedLine("CookieContainer is null");
         return;
     }
     System.Net.CookieCollection cookies = container.GetCookies(uri);
     PrintCookies(cookies, "PrintCookies for Uri " + uri.ToString());
 }