且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

尝试创建新的 Active Directory 用户时,Invoke(“SetPassword",pwd) 抛出“RPC 服务器不可用"

更新时间:2023-02-23 23:13:03

好的,我搞定了:

 dirEntry = new DirectoryEntry(ldapPath, domainAdminUser, domainAdminPassword);
    dirEntry.Invoke("SetPassword", new object[] { newPassword });
    dirEntry.Properties["LockOutTime"].Value = 0; //unlock account

ldapPath 应该包含我们尝试更改的用户的完整 DN,因此它应该类似于:

ldapPath should include the full DN of the user we're trying to change , so it should look something like:

string ldapPath = "LDAP://ad.domain.com:389/CN=username,OU=Users,DC=ad,DC=domain,DC=com"