Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - change password as per users' requests

Reply
 
Old 10-25-2008   #1 (permalink)


Vista Home
 
 

change password as per users' requests

Hi Friends,
I m new to progrmamming field and have created a userform that allows the user to enter and work according to his needs however as per one of my user's request , he asked me if I could give them an option to change password . Hence I requets to all genius programers to help me write this in VB Script( I am using Excel as the platform )

My System SpecsSystem Spec
Old 10-25-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: change password as per users' requests


"nerd" <guest@xxxxxx-email.com> wrote in message
news:b4ce69e7b6755dd7e7b97d8188545c6d@xxxxxx-gateway.com...
Quote:

>
> Hi Friends,
> I m new to progrmamming field and have created a userform that allows
> the user to enter and work according to his needs however as per one of
> my user's request , he asked me if I could give them an option to change
> password . Hence I requets to all genius programers to help me write
> this in VB Script( I am using Excel as the platform )
>
I assume a domain user that wants to change his own password. In VBScript
you bind to the user object, then use the ChangePassword method of the
object. You pass the old and new passwords to the method. You need the full
Distinguished Name of the current user to bind to the object, but that can
be retrieved from the ADSystemInfo object. For example, a script that
prompts for required values could be:
==========
Option Explicit
Dim objSysInfo, strUserDN, objUser, strOldPassword, strNewPassword

' Retrieve DN of current user.
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.UserName

' Bind to user object with Distinguished Name.
Set objUser = GetObject("LDAP://" & strUserDN)

' Prompt for old password.
strOldPassword = InputBox("Enter old password")

' Prompt for new password.
strNewPassword = InputBox("Enter new password")

Call objUser.ChangePassword(strOldPassword, strNewPassword)
========
If the user is a local user you must use the WinNT provider (instead of the
LDAP provider). You must bind with the NetBIOS name of the user, but you can
retrieve that from the wshNetwork object. Then the code could be:
=========
Option Explicit
Dim objNetwork, strUser, strComputer, objUser, strOldPassword,
strNewPassword

' Retrieve local user and computer.
Set objNetwork = CreateObject("Wscript.Network")
strUser = objNetwork.UserName
strComputer = objNetwork.ComputerName

' Bind to user object in local SAM account database.
Set objUser = GetObject("WinNT://" & strComputer & "/" & strUser & ",user")

' Prompt for old password.
strOldPassword = InputBox("Enter old password")

' Prompt for new password.
strNewPassword = InputBox("Enter new password")

Call objUser.ChangePassword(strOldPassword, strNewPassword)
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
New user - repeated password requests in WM Vista mail
Users are unable to change domain password Vista security
Privision User must change password at next logon, if passwordchanged, set password never expire VB Script
Password protect users Vista networking & sharing
Windows e-mail and password requests Vista account administration


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46