The following code snippet is what I use...
object[] parameters = null;
parameters = new object[1];
parameters[0] = "password";
try
{
de.Invoke("SetPassword", parameters);
}
catch
{
;
}
The string "password" should be replaced with the desired password.
The de object is a DirectoryEntry object representing the (user)
object you want to set or change the password for. You should also
add code to the catch block but what is added will be up to you.
This will set what I call the internal password (the one that cannot
be retrieved). As mentioned, we store a "mirrored" copy of the
password in another attribute. This is set just like any other
attribute (using a custom encryption component in our case).
There a few things I would like to mention in case you are not
already aware of them (please disregard them if you are).
First, if you use the code above, by default, you must make a
connection to ADAM via SSL. Configuring a certificate for use with
ADAM is not too bad once you have done it a time or two. You can set
a flag so that password resets will work over a non-secure port but
this is not recommended for a production environment.
Second, when setting a password in ADAM, the password policy of all
accounts in ADAM is inherited from the password policy for the
account (NETWORK SERVICE, domain account, etc.) that is used to run
the ADAM service.
Third, there is a book titled "The .NET Developer's Guide to
Directory Services Programming" available. I do not own this book
personally but I have been told it is good. A consultant that helped
us once had this book which is what he used to help me figure out the
code above. The web site for this book
(http://www.directoryprogramming.net) has a good forum to post
questions. I think this site is really intended for discussions
about the book but one of the authors (Joe Kaplan) is nice enough to
answer other questions (and has done so a number of times for me).
This is a bit off topic but if you ever find yourself working with
(swearing at) the ADFS product, this site has an excellent forum for
this product as well.