I am trying to create new user in AD with code as -
var principalContext = GetPrincipalContext(txtDomain.Text, txtAdminUser.Text, txtAdminPassword.Text);
var userPrincipal = new UserPrincipal(principalContext, txtUsername.Text, txtPassword.Text,true);
//User details
userPrincipal.UserPrincipalName = txtUsername.Text;
userPrincipal.GivenName = txtGivenName.Text;
userPrincipal.Surname = txtSurname.Text;
userPrincipal.PasswordNeverExpires = true;
userPrincipal.AllowReversiblePasswordEncryption = true;
userPrincipal.Save();
User gets created as enabled.
But if I use options PasswordNeverExpires or AllowReversiblePasswordEncryption (values set to true) after creating user, then the user enable state changes to disable.
By after, I mean that user had created in AD. And we are modifying user's mentioned attributes then after.
I'm unable to find genuine reason for this. Can you please help me to get why it's behaving weird?