Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Private Method
- private static void EnableADUserUsingUserPrincipal(string username)
- {
- try
- {
- PrincipalContext principalContext = new PrincipalContext(ContextType.Domain);
- UserPrincipal userPrincipal = UserPrincipal.FindByIdentity
- (principalContext, username);
- userPrincipal.Enabled = true;
- userPrincipal.Save();
- MessageBox.Show("AD Account Enabled for {0}", username);
- Form1 f1 = new Form1();
- f1.StatusTextBox.Text = "Account Enabled";
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- }
Add Comment
Please, Sign In to add comment