This code failed on this line with unknown error (0x80005000)
using System;
using System.DirectoryServices;
// correct the userPath!!!
string userPath = "WinNT://"+Environment.MachineName+"/"+Environment.UserDomainName+"//"+Environment.UserName;
using (DirectoryEntry userEntry = new DirectoryEntry(userPath))
{
object[] password = new object[] {"newPwd", "oldPwd"};
object ret = userEntry.Invoke("ChangePassword", password);
userEntry.CommitChanges();
}
You should try to avoid using the WinNT:
provider for ADSI - it's old, it's only there for backward compatibility, and it's severely limited in its capabilities.
Is this a user account in a network environment? If so, use the LDAP://
provider instead - it's much more powerful and more flexible in many ways.
Where exactly is your code failling? It's not clear from your post. On the .Invoke()
or on the .CommitChanges()
call?
User contributions licensed under CC BY-SA 3.0