开发者

How To get currently logged in Active directory user name in C#

开发者 https://www.devze.com 2023-01-21 06:04 出处:网络
I want to get currently logged in active directory user name/details. Here, User does log in to machine with its AD username开发者_C百科 and password. How can i get this user name and other details

I want to get currently logged in active directory user name/details.

Here, User does log in to machine with its AD username开发者_C百科 and password. How can i get this user name and other details in Global.asax file for Application_AuthenticateRequest() Event.

I have used System.Security.Principal.WindowsIdentity.GetCurrent().Name But, when it hosted on IIS 6.0 returns Server's users credentials. such as "domain\username". I have currently enabled Anonymous Access and Integrated Authentication. And in project using Form Authentication.

Should I use System.Directory.dll


If you want the windows credentials, then you should disable anonymous access, and use windows security instead of forms authentication in your application.

You use HttpContext.User.Identity.Name to get the name of the logged in user inside your application. If you use forms auth, then you will get the name of the logged in forms-user, if you use integrated security and windows auth, then you get the AD name of the user.

0

精彩评论

暂无评论...
验证码 换一张
取 消