vml19
vml19

Reputation: 3864

Validating a Active Directory User

To check for a user's existence in Active Directory, which one is the better .Net library to use?

System.Web.Security.ActiveDirectoryMembershipProvider 

or

System.DirectoryServices

I'm using using System.DirectoryServices and I feel it is the exact one to use. I do see there are similar features provided in here.

Please advise.

Upvotes: 2

Views: 1592

Answers (1)

marc_s
marc_s

Reputation: 755321

Since you're on .NET 4.0, you should check out the System.DirectoryServices.AccountManagement (S.DS.AM) namespace. Read all about it here:

Basically, you can define a domain context and easily find users and/or groups in AD:

// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);

// find a user
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName");

if(user != null)
{
   // do something here....     
}

The new S.DS.AM makes it really easy to play around with users and groups in AD!

Upvotes: 2

Related Questions