当任一属性为true时,AD用户将被禁用

时间:2015-01-15 11:44:45

标签: c# active-directory account-management

我正在尝试在AD中创建新用户,代码为 -

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();

用户创建为已启用。

但是如果我在创建用户后使用选项 PasswordNeverExpires AllowReversiblePasswordEncryption (值设置为true),那么用户启用状态更改为禁用

之后,我的意思是用户在AD中创建了。我们正在修改用户提到的属性。

我无法找到真正的理由。你能帮助我解决它为什么表现得很奇怪吗?

0 个答案:

没有答案