change password from .NET program

  • Thread starter Thread starter Dan Schullman
  • Start date Start date
D

Dan Schullman

How can I change a user's password from a .NET program? Is there perhaps a
class for it, or maybe a WMI interface, or some executable I can run? I've
done some MSDN searches but haven't turned up anything so far.

Thanks in advance,
Dan S.
 
If you are talking Windows 2000 or greater, I would look at Active Directory
as a possibility. As I have not done this, I can only guess where you would
best find the info you need.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
This is how we used to do it in old com days..

Set o = GetObject("WinNT:")
Set usr = o.OpenDSObject("WinNT://" & txtDomain & "/" & txtUserName,
txtUserName, txtOldPassword, 1)
usr.ChangePassword txtOldPassword, txtNewPassword

As indicated it uses Active Directory interface....

Regards.
 
Thanks for the pointers. I found and ended up using the .NET DirectoryEntry
class and IADsUser.SetPassword().

--Dan S.
 
By the way, the program takes several seconds to run [on a 2.4 GHz XP Pro
system, with less than 10 users], even when I only query for a few items
(FullName, Description, LastLogin) and do NOT set a password. This doesn't
seem right. Is there something I can do to speed it up?

Here's the J# code:

String adsPath = "WinNT://" + Environment.get_MachineName()
+ "/" + username + ",user";
DirectoryEntry entry = new DirectoryEntry( adsPath );
IADsUser user = (IADsUser) entry.get_NativeObject();
System.out.println( "lastLogin: " + user.get_LastLogin() );
System.out.println( "fullname: " + user.get_FullName() );
System.out.println( "description: " + user.get_Description() );

Thanks,
Dan S.
 
Back
Top