简体   繁体   English

将 Windows 用户名设置为 header IIS 10

[英]Set Windows username as header IIS 10

I am using IIS 10 with Windows authentication.我正在使用 IIS 10 和 Windows 身份验证。 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?我可以在日志文件中看到 windows 用户名,我正在寻找一种方法来捕获它(在身份验证后)并使用重写将其存储在请求中 header 这可能没有太多大惊小怪吗?

You can do this with VB or C#, I will give an example of both您可以使用 VB 或 C# 来执行此操作,我将给出两者的示例

VB.NET: VB.NET:

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

C#: C#:

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

Hopefully this is what you needed希望这是你需要的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM