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.
精彩评论