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);
        }
        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
        }
 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());
 }
        public static void PrintCurrentRow(BindingManagerBase bm, string sComment /* = "" */)
        {
            PrintIfNotEmpty(sComment);
            //        ' Check the type of the Current object. If it is not a
            //        ' DataRowView, exit the method.
            if (bm.Current.GetType() != typeof(DataRowView))
            {
                return;
            }
            DataRowView drv = (DataRowView)bm.Current;

            DebugOutputHelper.PrintRow(drv.Row, "");
        }
 public static void PrintView(DataView view, string sComment)
 {
     PrintIfNotEmpty(sComment);
     if (view == null)
     {
         Debug.WriteLine("view is null");
         return;
     }
     Debug.WriteLine(String.Format("view: '{0}' with {1} rows ", view.Table.TableName, view.Count));
     for (int i = 0; i < view.Count; i++)
     {
         DebugOutputHelper.PrintRow(view[i].Row, "");
     }
 }