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.

Re: change password from .NET program by Cowboy

Cowboy
Fri Oct 24 09:31:38 CDT 2003

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!
**********************************************************************
"Dan Schullman" <newsuser@westerville.ohmy> wrote in message
news:upSRjKjmDHA.2232@TK2MSFTNGP09.phx.gbl...
> 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.
>
>



Re: change password from .NET program by NetPointer

NetPointer
Fri Oct 24 16:04:11 CDT 2003

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.


"Dan Schullman" <newsuser@westerville.ohmy> wrote in message
news:upSRjKjmDHA.2232@TK2MSFTNGP09.phx.gbl...
> 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.
>
>



Re: change password from .NET program by Dan

Dan
Fri Oct 24 18:41:20 CDT 2003

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

--Dan S.



Re: change password from .NET program by Dan

Dan
Fri Oct 24 19:24:06 CDT 2003

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.