Hi Johnny,
To change a password, we can use the IADsUser::ChangePassword or
NetUserChangePassword API.
How To Change Passwords Programmatically in Windows NT, Windows 2000, or
Windows XP (151546)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;151546
When using the IADsUser::ChangePassword or IADsUser::SetPassword methods
from DirectoryEntry::Inoke, it is not necessary to call the
DirectoryEntry::CommitChanges method to force the local cache to server.
The password change methods do this work for you.
The following code illustrates how to Invoke ChangePassword from C#.Net.
using System;
using System.DirectoryServices;
namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
try
{
DirectoryEntry de = new
DirectoryEntry("LDAP://cn=Holly,Ou=Red
Dwarf,dc=br549,dc=nttest,dc=microsoft,dc=com", "br549\\Fordp", "fordp10+",
AuthenticationTypes.Secure);
String strPwdOld ;
String strPwdNew ;
strPwdOld = "holly11";
strPwdNew = "holly10";
de.Invoke( "ChangePassword", new
Object[]{strPwdOld, strPwdNew});
Console.WriteLine(de.Name);
}
catch( System.Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.