Set Windows username as header IIS 10

Viewed 35

I am using IIS 10 with Windows authentication. I can see the windows username in the log files, and i am looking for a way to capture it (after authentication) and using rewrite to store it in a request header Is that possible without too much fuss?

1 Answers

You can do this with VB or C#, I will give an example of both

VB.NET:

If User.Identity.IsAuthenticated Then
    Label1.Text = User.Identity.Name

C#:

if (User.Identity.IsAuthenticated)
    Label1.Text = User.Identity.Name;

Hopefully this is what you needed

Related