执行至:
de.Invoke("SetPassword",new object []{newPassword});抛异常。 在AD服务器上运行正常,但在加入域的服务器运行就出错。可以断定应该不是程序的问题,但找了很久也没找到解决办法。后来在http://www.highdots.com/forums/asp-net-security/change-password-active-directory-webapplication-700434.html看到一段话: You may need to experiment with different variations on the dcDNS variable and you may need to remove the ServerBind flag if you are using a NETBIOS name. Also, you may need to remove the Sealing flag as well, but be warned that in order to set or change passwords, some sort of encrypted channel (SSL or Kerberos) must be available. 突然想到犯了一个低级错误!没有把DNS设置正确!!因为测试AD服务器也是DNS服务器,所以需要把AD服务器的地址配到本机的DNS中。配置后运行成功!