How to get user name using Windows authentication in asp.net?

前端 未结 7 1872
抹茶落季
抹茶落季 2020-12-23 11:43

I want to get user name using Windows authentication

Actually I implemented \"Sign in as different user\",when click this button Windows security will appear there w

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-23 12:30

    You can get the user's WindowsIdentity object under Windows Authentication by:

    WindowsIdentity identity = HttpContext.Current.Request.LogonUserIdentity;
    

    and then you can get the information about the user like identity.Name.

    Please note you need to have HttpContext for these code.

提交回复
热议问题