[英]How to set force reset password when login with temporary password in active directory from c# .net
I have the following code to reset the password for the user in active directory and the code is working fine. 我有以下代码可以重置活动目录中用户的密码,并且该代码工作正常。 Somehow I would like to force the user to reset their password when they first login into the computer with the temporary password.
我想以某种方式强迫用户在首次使用临时密码登录计算机时重置其密码。 I tried to use both
uEntry.Properties["pwdLastSet"].Value = 0;
我试图同时使用
uEntry.Properties["pwdLastSet"].Value = 0;
and uEntry.Properties["PasswordExpired"].Value = 1
, it's doesn't work. 和
uEntry.Properties["PasswordExpired"].Value = 1
,它不起作用。 Anyone know how can I make it happen? 有人知道我该如何实现吗?
DirectoryEntry uEntry = new DirectoryEntry(userDn, "abc", "abc123");
uEntry.Invoke("SetPassword", new object[] { password });
uEntry.Properties["pwdLastSet"].Value = 0;
uEntry.Close();
Some points to note: 需要注意的几点:
uEntry.CommitChanges();
uEntry.CommitChanges();
to commit the change after setting pwdLastSet The userDn
in new DirectoryEntry(userDn, "abc", "abc123");
new DirectoryEntry(userDn, "abc", "abc123");
的userDn
new DirectoryEntry(userDn, "abc", "abc123");
should be an LDAP path instead of really a DN. 应该是LDAP路径,而不是真正的DN。 For example:
例如:
LDAP://example.com/CN=user,DC=example,DC=com
instead of CN=user,DC=example,DC=com
LDAP://example.com/CN=user,DC=example,DC=com
而不是CN=user,DC=example,DC=com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.