Created
February 4, 2012 19:30
-
-
Save dalexsoto/1739634 to your computer and use it in GitHub Desktop.
Active Directory Account Manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.DirectoryServices.AccountManagement; | |
...... | |
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, ADDomain)) | |
{ | |
var user = UserPrincipal.FindByIdentity(pc, IdentityType.SamAccountName, ADDomain + "\\" + username); | |
var group = GroupPrincipal.FindByIdentity(pc, "Admins. del dominio"); | |
var y = user.IsMemberOf(group); | |
var z = user.GetGroups().ToList(); | |
// validate the credentials | |
return pc.ValidateCredentials(username, password); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment