How to get the current user's Active Directory details in C#

后端 未结 4 1309
天命终不由人
天命终不由人 2020-11-30 20:56

I am working on an C# and ASP.Net application, that uses Windows Authentication.

i.e. in Web.config:


    

        
4条回答
  •  情深已故
    2020-11-30 21:35

    If you're using .NET 3.5 SP1+ the better way to do this is to take a look at the

    System.DirectoryServices.AccountManagement namespace.
    

    It has methods to find people and you can pretty much pass in any username format you want and then returns back most of the basic information you would need. If you need help on loading the more complex objects and properties check out the source code for http://umanage.codeplex.com its got it all.

    Brent

提交回复
热议问题