Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WMI to set user password

17 views
Skip to first unread message

Ali AYEN

unread,
Jan 23, 2004, 10:01:28 AM1/23/04
to
Can I set user password on remote computer with WMI ?
 
Ali AYEN
Teknik Destek - NiobeWEB Hosting
ali...@niobeweb.net - www.niobeweb.net
Gaziosmanpasa Blv. Sureyya Reyent Ishani
No.507 Cankaya / IZMIR
Tel : 0.232.441 0678
Fax : 0.232.441 0893

Torgeir Bakken (MVP)

unread,
Jan 24, 2004, 11:04:59 PM1/24/04
to
Ali AYEN wrote:

> Can I set user password on remote computer with WMI ?

Hi

As far as I know, no. But you can use the WinNT object for this:


sNewPwd = "testpassword"
sUser = "some user name here"
sComputer = "some computer name or IP address here"

Set oUser = GetObject("WinNT://" & sComputer & "/" & sUser & ",user")
oUser.SetPassword sNewPwd
oUser.SetInfo


' to change password:
'sOldPwd = "the oldpwd"
'sNewPwd = "the newpwd"
'oUser.ChangePassword(sOldPwd, sNewPwd)
'oUser.Setinfo

If you need to use explicit credentials

' Insert code to securely retrieve the username and password (sUsername,
sPassword)

Const ADS_SECURE_AUTHENTICATION = 1
sComputer = "some computer name or IP address here"

Set oDSO = GetObject("WinNT:")
Set oComputer = oDSO.OpenDSObject _
("WinNT://" & sComputer, sUsername, sPassword, ADS_SECURE_AUTHENTICATION)


IADsOpenDSObject::OpenDSObject
http://msdn.microsoft.com/library/en-us/adsi/adsi/iadsopendsobject_opendsobject.asp

(note that the constant ADS_SECURE_AUTHENTICATION mentioned in the link above
needs to be explicit defined to 1 in a VBScript)

INFO: User Authentication Issues with ADSI WinNT Provider
http://support.microsoft.com/default.aspx?scid=KB;en-us;218497


An example on how to use OpenDSObject:

Modifying User Cannot Change Password (WinNT Provider)
http://msdn.microsoft.com/library/en-us/adsi/adsi/modifying_user_cannot_change_password_winnt_provider.asp


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


0 new messages