get user name asp.net windows auth

家住魔仙堡 提交于 2020-01-06 08:57:11

问题


SO i made a simple web form, set in windows auth in iis. 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 ?


回答1:


If you using asp.net membership provider you can get the current logged user

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

User.Identity.IsAuthenticated  

can be used to identify whether user successfully logged in or not




回答2:


<identity impersonate="true" /> in web config , fixed my problem.
http://msdn.microsoft.com/en-us/library/ff647076.aspx helped me.
thanks.



来源:https://stackoverflow.com/questions/7615458/get-user-name-asp-net-windows-auth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!