如何在asp.net中没有Windows登录提示的情况下获取Windows登录用户名

问题描述:



我使用下面提到的代码来获取登录的Windows用户名,

IIdentity WinId = HttpContext.Current.User.Identity;

WindowsIdentity wi =(WindowsIdentity)WinId;

string user_name = wi.Name;



此代码


1.我在IIS中取消选中匿名身份验证。

2.启用Windows身份验证。



但是在运行它时询问Windows登录提示。然后我才会记录Windows用户名。



我需要使用匿名身份验证来获取Windows用户名。 !!!!!!!



请做...

Hi,
I using below mention code to get logged windows username,
IIdentity WinId = HttpContext.Current.User.Identity;
WindowsIdentity wi = (WindowsIdentity)WinId;
string user_name = wi.Name;


for this code,
1.I have unchecked anonymous authentication in IIS.
2.Enabled windows authentication.

But while running it's asking windows login prompt. then only i m getting logged windows username.

I need using anonymous authentication to get windows username. !!!!!!!

Please do needful...

如果要获取客户端使用的Windows用户名是使用您的应用程序,则必须使用Windows身份验证或要求用户在应用程序的某处输入用户名。
If you want to get the windows user name of the client use is using your application, you have to either use windows authentication or ask the user to enter the user name somewhere in your application.