Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using(var pc = new PrincipalContext(ContextType.Domain))
- {
- using(var up = new UserPrincipal(pc))
- {
- up.SamAccountName = username;
- up.EmailAddress = email;
- up.SetPassword(password);
- up.Enabled = true;
- up.ExpirePasswordNow();
- up.Save();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement