获取Windows用户ID使用窗体身份验证时 [英] Getting Windows User ID When Using Forms Authentication

查看:632
本文介绍了获取Windows用户ID使用窗体身份验证时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作对我们的内联网运行的ASP.NET MVC应用程序。我们正在使用窗体身份验证,但是设置的用户名将会是相同的Active Directory用户名。我试图找到一种方法,pre-填充的登录用户名字段与Windows用户名,但不能找到一种方法来访问当前的Windows用户标识。

I'm working on an ASP.NET MVC app running on our intranet. We are using forms authentication, however the usernames set up will be the same as the Active Directory usernames. I'm trying to find a way to pre-populate the login username field with the Windows username, but can't find a way to access the current Windows user identity.

System.Environment.UserDomainName 返回IIS APPPOOL

System.Environment.UserDomainName returns "IIS APPPOOL"

System.Security.Principal.WindowsPrincipal.Current.Identity 返回GenericIdentity

System.Security.Principal.WindowsPrincipal.Current.Identity returns a GenericIdentity

HttpContext.Request.LogonUserIdentity.Name 返回NT AUTHORITY \ IUSR

HttpContext.Request.LogonUserIdentity.Name returns "NT AUTHORITY\IUSR"

我不希望进行身份验证的Windows用户或登录到网站的Windows用户,我只是想阅读的用户名。有没有办法做到这一点,而使用窗体身份验证,而不是Windows身份验证?

I do not want to authenticate the Windows user or login to the website as the Windows user, I just want to read the username. Is there any way to do this whilst using Forms Authentication rather than Windows Authentication?

推荐答案

关闭Windows身份认证在IIS那么应该一切工作的可能。

Turn off the Windows Authentification in the IIS then should everything work possible

这篇关于获取Windows用户ID使用窗体身份验证时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆