ADAM setpassword 0x80005008
Thursday, December 18, 2008 5:40:00 PM
If I tried and set the password in ADAM in C# it gave the next error:
Message: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80005008): Exception from HRESULT: 0x80005008.
As described in this page:
http://social.technet.microsoft.com/forums/en-US/exchangesvrdevelopment/thread/bb518eb3-02cb-4b3c-9a18-4ce85f245131/
They say there is a fix for that from Microsoft. I didn't try that but I found another solution to my problem.
So, I was:
1. Going against ADAM
2. Through SSL
3. .NET 1.1
The code I had was exactly from the page above:
de.Invoke("SetOption", new object[] {(int)ADS_OPTION_PASSWORD_PORTNUMBER, (object)_portNo });
de.Invoke("SetOption", new object[] { (int)ADS_OPTION_PASSWORD_METHOD, (object)ADS_PASSWORD_ENCODE_CLEAR});
de.Invoke("SetPassword", new object[] {newPassword});
What is sneacky here is the ADS_PASSWORD_ENCODE_CLEAR constant, btw the constants are declared like:
const long ADS_OPTION_PASSWORD_PORTNUMBER = 6;
const long ADS_OPTION_PASSWORD_METHOD = 7;
const int ADS_PASSWORD_ENCODE_REQUIRE_SSL = 0;
const int ADS_PASSWORD_ENCODE_CLEAR = 1;
As you can see the ADS_PASSWORD_ENCODE_REQUIRE_SSL is not used in my case.
So, what I had to change is from this:
de.Invoke("SetOption", new object[] { (int)ADS_OPTION_PASSWORD_METHOD, (object)ADS_PASSWORD_ENCODE_CLEAR});
To this:
de.Invoke("SetOption", new object[] { (int)ADS_OPTION_PASSWORD_METHOD, (object)ADS_PASSWORD_ENCODE_REQUIRE_SSL});
And it worked.
Remeber this is changing the password in ADAM through SSL.
And by the way on your DirectoryEntry object set the AuthenticationType to AuthenticationTypes.SecuredSocketLayer
Related links:
1. http://msdn.microsoft.com/en-us/library/aa772136(VS.85).aspx
2. http://msdn.microsoft.com/en-us/library/system.directoryservices.authenticationtypes.aspx
3. http://social.technet.microsoft.com/forums/en-US/exchangesvrdevelopment/thread/bb518eb3-02cb-4b3c-9a18-4ce85f245131/
4. http://www.techreplies.com/windows-2003-77/setting-user-passwords-adam-vb-net-466581/
5. http://directoryprogramming.net/forums/9/ShowForum.aspx

