PrincipalContext ctx = new PrincipalContext(contextType, domainname, username,password); UserPrincipal user = UserPrincipal.FindByIdentity(ctx, userName);