asp.net Web应用程序中的Windows身份验证 [英] windows authentication in asp.net web app

查看:94
本文介绍了asp.net Web应用程序中的Windows身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我开发了一个具有Windows身份验证的Web应用.
该应用程序将在Intranet中运行.因此无需任何登录页面.
现在,当用户从其桌面访问应用程序时,我想获取已登录计算机的用户的IP地址a和用户名.

我已从IIS的安全性"部分禁用了匿名用户,并启用了Windows身份验证.

也已在web.config中编写了Windows身份验证.
现在,我通过写
作为用户名得到的是网络服务"作为用户名 ``System.Web.HttpContext.Current.User.Identity.Name''
我也尝试过使用Page.User.Identity.Name,但仍无法获得计算机用户名的用户名.

请指导.


Priyanka Rao

Hi,

I have developed one web app with windows authentication.
This app will be working in intranet.So no need of any login page in that.
Now when the user accessess the app from his desktop , i want to fetch the ip address a and username of the user who has logged into the machine.

I have disabled anonymous user in security section from IIS and enabled the windows authentication.

Also have written windows authentication in web.config.
Now whaty i am getting as username is ''Network Service'' as Username by writing
''System.Web.HttpContext.Current.User.Identity.Name''
I have also tried Page.User.Identity.Name but still not getting Username of the machine''s username.

Please guide.


Priyanka Rao

推荐答案

string strAccount = HttpContext.Current.User.Identity.Name.ToString();
string strUserName = strAccount .Split("\\".ToCharArray())[1];


这篇关于asp.net Web应用程序中的Windows身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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