Windows Vista Forums

change password as per users' requests
  1. #1



    Newbie
    Join Date : Oct 2008
    Posts : 1
    Vista Home
    Local Time: 03:51 AM

    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

  2. #2


    Richard Mueller [MVP] Guest

    Re: change password as per users' requests


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

    >
    > 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

change password as per users' requests problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
2008 R2.. a way to offsite change password for domain users on vpn markm75g Server General 2 02 Apr 2010
Users are unable to change domain password Kevin M Vista security 9 10 Mar 2010
Re: Users cannot change password on Win2k8 server Meinolf Weber [MVP-DS] Server General 0 13 Jan 2010
Users cannot change password on Win2k8 server gjl_support Server General 5 13 Jan 2010
Users cannot change password in win2k8 terminal server gjl_support Server General 0 22 Dec 2009