检索登录名的问题 [英] problem on retrieving login name
本文介绍了检索登录名的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
在ASP.NET C#中我试图检索用户登录的用户名
Ii试过
1)
string userName = System.Security.Principal.WindowsIdentity.GetCurrent()。Name;
2)
string userName = Membership.GetUser()。UserName;
但是UserName返回NULL
知道我还应该尝试什么?
Hi guys,
In a ASP.NET C# I'm trying to retrieve the user name where a user logins
Ii tried
1)
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
2)
string userName = Membership.GetUser().UserName;
but UserName return NULL
any idea what else i should try?
推荐答案
除非您的ASP.NET服务器或成员资格提供程序使用相同的Windows帐户数据库,无论是SAM数据库还是ActiveDirectory,都无法获得用户呈现Windows身份的DisplayName。
我不是ASP.NET网站的专家,但我认为您的网站还必须禁用匿名身份验证并启用Windows身份验证。
Unless you ASP.NET server or membership provider is using the same Windows account database, be it a SAM database or ActiveDirectory, you cannot get the DisplayName of the user presented Windows Identity.
I'm no expert on ASP.NET websites, but I think your website would also have to have Anonymous Authentication disabled and turn on Windows Authentication.
这篇关于检索登录名的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文