In that post I stated that everything you need to query the Active Directory in .NET lives in the System.DirectoryServices, well that was a lie. .NET Framework 3.5 introduced the System.DirectoryServices.AccountManagement namespace.
I learned about this namespace today, and wow, it really is much better. I have rewritten our own Active Directory wrapper in less then a few hours.
All you need to know in general is that everything you do using the AccountManagement namespace needs to run under a PrincipalContext.
Let me show you two basic methods..
I commented out the original method which uses the DirectoryServices namespace. Can you see the difference?
Authenticate a user
Get the DisplayName of a user
The code hardly needs any explanation. Hope it helps!
No comments:
Post a Comment