简体   繁体   English

获取用户名asp.net Windows身份验证

[英]get user name asp.net windows auth

SO i made a simple web form, set in windows auth in iis. 所以我做了一个简单的Web表单,在IIS中的Windows Auth中设置。 then i deployed it on my server and i try to log in. it prompts me a login box, i enter my infos, looks likes its working fine with active directory. 然后我将其部署在服务器上,然后尝试登录。它提示我一个登录框,我输入我的信息,看起来像在活动目录下正常工作。

if i enter something wrong it wont work etc. 如果我输入错误,它将无法正常工作。

obviously i need to know who is the logged on user 显然我需要知道谁是登录用户

Response.Write(HttpContext.Current.User.Identity.Name.ToString());

i found this in other threads, but it wont work for me... 我在其他线程中发现了这个,但是对我来说不起作用...

how do i get the info filled in the login box ? 我如何在登录框中填写信息?

If you using asp.net membership provider you can get the current logged user 如果您使用asp.net membership提供程序,则可以获取当前登录的用户

System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();

User.Identity.IsAuthenticated  

can be used to identify whether user successfully logged in or not 可用于识别用户是否成功登录

<identity impersonate="true" /> in web config , fixed my problem. Web配置中的<identity impersonate="true" />修复了我的问题。
http://msdn.microsoft.com/en-us/library/ff647076.aspx helped me. http://msdn.microsoft.com/en-us/library/ff647076.aspx帮助了我。
thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM