Cannot set password for AD User

  • Thread starter Thread starter Kodiak
  • Start date Start date
K

Kodiak

I create a DirectoryEntry object called userEntry and I am calling the
Invoke method. I am calling the SetPassword method and passing the
new password and I am using the DirectoryServices namespace in my
code. The problem that I an experiencing is everytime I call the
SetPassword method I get an exception called Login Failure: unknown
username and password. I have checked the account I am using to use
to authenticate to AD and the account is not disabled or locked out
and the password does not need to be changed on the next login. I am
using secure mode to connect to AD and I can create the AD account
without any problems, but when I set the password I always get an
error. I really do not want to use impersonation as a solution so any
advice you can provide me is much appreciated.

Thanks,
Richard
 
you are probaly best asking AD question to 'Joe' in the
microsoft.public.adsi.general newsgroup,

but here is the code I used:

private void ChangePassword(System.DirectoryServices.DirectoryEntry entry,
string oldPassword, string newPassword)
{
object[] pwd = newobject[] {oldPassword, newPassword};
entry.Invoke("ChangePassword", pwd); //Commit the changes back into
directory
service entry.CommitChanges();
entry.RefreshCache();
}

check out the following url

http://osdir.com/ml/windows.devel.dotnet.advanced/2003-06/msg00079.html
 
Back
Top