Search code examples
asp.netweb-servicesdirectoryserviceschange-password

DirectoryEntry can not ChangePassword due to Domain Controller. Help?


This is suppose to be a basic password change method using DirectoryServices in ASP.NET.

The code:

String path = ConfigurationManager.AppSettings["LDAPServer"] + myDN;
DirectoryEntry de = new DirectoryEntry(path, @"Domain A\" + myUserId, myPassword, AuthenticationTypes.Secure);
de.Invoke("ChangePassword", new object[] { myPassword, myNewPassword});

This runs fine if I run locally via virtual IIS (using Visual Studio). However, if I publish this to production, I get:

Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied. (Exception from HRESULT: 0x80070547)

The only difference between that might be that my computer is on Domain A but the published server is on Domain B. Domain A and Domain B are trusted and Domain A is parent of Domain B.

Anyone have any idea where and how the error is produced?

EDIT: Perhaps I should add that this is a Web Service. Another app will throw necessary information to verify and the Web Service will change the password.


Solution

  • Sorry to mark yours as answer and take it away. I was actually getting another error because of identity thing and I thought this issue was solved and moved unto next issue.

    Anyway, I have solved it by changing the PATH of DirectoryEntry. Before it was:

    LDAP://server.domain/DistinguishedName

    but I changed it to

    LDAP://DistinguishedName

    then it was all working fine.