简体   繁体   English

使用System.DirectoryServices更改密码时收到错误

[英]Receiving error in changing the password using System.DirectoryServices

I've a web service deployed on one of the servers which internally uses System.DirectoryServices to change password using following code : 我已经在其中一台服务器上部署了一个Web服务,该服务器内部使用System.DirectoryServices使用以下代码更改密码:

            DirectoryEntry obDirectoryEntry = GetCurrentUserDirectoryEntry();
            obDirectoryEntry.Invoke("ChangePassword", new object[] { sOldPassword, newPassword });
            obDirectoryEntry.CommitChanges();
            obDirectoryEntry.Close();

This web service is working fine when hit from a particular different domain, but fails with following error when hit from some other : 当从特定的不同域中命中时,此Web服务工作正常,但是从其他域中命中时,失败并显示以下错误:

Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied. 由于计算机不可用或访问被拒绝,所以无法从域控制器读取配置信息。

What could be the reason of this? 这可能是什么原因? And what is the workaround? 解决方法是什么?

Thanks a lot, Ishan 非常感谢Ishan

Need more info about the particular network setup, but a workaround would be to specify the DomainController that works. 需要有关特定网络设置的更多信息,但是一种解决方法是指定有效的DomainController。

In your GetCurrentUserDirectoryEntry() method, you can use the overload: 在您的GetCurrentUserDirectoryEntry()方法中,可以使用重载:

var user = new DirectoryEntry("LDAP://WorkingDomainController", ...);

See: http://www.codeproject.com/KB/system/everythingInAD.aspx#7 请参阅: http//www.codeproject.com/KB/system/everythingInAD.aspx#7

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM