[英]How to get username input from Windows Authentication in IIS?
在IIS中,我将身份验证设置为Windows。
2个问题:
有没有一种方法可以让我在加载页面之前获取用户为该弹出式身份验证窗口输入的用户名,
有什么办法可以使他们每次访问该页面时都需要登录?
谢谢。
要回答您的第一个问题,这是如何通过Windows身份验证访问用户:
WindowsPrincipal winPrincipal = (WindowsPrincipal)HttpContext.Current.User;
还有其他选项,例如:
WindowsIdentity winId = WindowsIdentity.GetCurrent();
WindowsPrincipal winPrincipal = new WindowsPrincipal(winId);
要么
WindowsPrincipal winPrincipal = (WindowsPrincipal) Thread.CurrentPrincipal();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.