Hi Everyone
I am attempting to write an application to reset a users ad password.
The code looks like this:
public string resetPassword(string fullname)
{
directorySearcher = new DirectorySearcher(directoryEntry);
//Set a filter for users using the supplied domainID
directorySearcher.Filter = "(&(objectClass=user)(mail=" + email+ "))";
result = directorySearcher.FindOne();
string newPassword = "";
Random rnd = new Random();
PasswordGenerator makePassword = new PasswordGenerator(rnd, 8);
newPassword = makePassword.Generate();
result.GetDirectoryEntry().Invoke("setPassword", newPassword);
directoryEntry.CommitChanges();
//MessageBox.Show(" The user's password has been reset. ", "Password Reset Successful");
return newPassword;
}
This works for most users. However on specific users it throws an "Access Denied" error on the "result.GetDirectoryEntry().Invoke("setPassword", newPassword);" line.
I don't quite know why this would be, as we have tried impersonating the users themselves, as well as using credentials of a system account with (supposedly) enough credentials to reset all but domain admin passwords.
Please Help.
Thanks
G
--Gambit--
Give me a lever long enough and I shall move the world.