Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.27 KB | None | 0 0
  1. using(var pc = new PrincipalContext(ContextType.Domain))
  2. {
  3.   using(var up = new UserPrincipal(pc))
  4.   {
  5.     up.SamAccountName = username;
  6.     up.EmailAddress = email;
  7.     up.SetPassword(password);
  8.     up.Enabled = true;
  9.     up.ExpirePasswordNow();
  10.     up.Save();
  11.   }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement