0

I have a web application which is set on forms and anonymous access. I have a default page on which I want to get the current windows logged in user, it's an ASP.Net application.

How can I do this?

1
  • 1
    You can't. Anonymous access means anyone can visit the page without telling the server his identity. WindowsIdentity.GetCurrent will just tell you the server account the web app is running under for anonymous access. Commented Sep 16, 2016 at 10:48

3 Answers 3

1

I believe you are looking for the HttpContext.User.Identity.Name

Sign up to request clarification or add additional context in comments.

Comments

0

Hello you can try with this code

   WindowsIdentity wi = WindowsIdentity.GetCurrent();
   var result = wi.Name;
   var anonymous = wi.IsAnonymous; //For ensure your authentification mode

You can use this code

System.Web.HttpContext.Current.User.Identity.Name

But you must ensure that yo have added your principal in your thread in your security package, maybe httpmodule. (If you have custom authentification and Authorization)

Comments

0

This code works:

        var w = WindowsIdentity.GetCurrent().Name;

        this.HttpContext.Trace.Warn(w);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.