Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Setting User Account Passwords

Microsoft® Windows® 2000 Scripting Guide

After creating a user account, you should set a password that a user will enter to log on to the network. If the password policies in the domain dictate that a password is required, you will have to set a password because Active Directory does not automatically add a password to a user account when it is created.

Table 7.3 shows the argument of the SetPassword method.

Table 7.3 Argument of the SetPassword Method

Argument

Type

Required

Default

Description

NewPassword

string

Yes

None

New password value

Scripting Steps

Listing 7.2 contains a script that sets a user account password to a specified value. To carry out this task, the script performs the following steps:

  1. Bind to the user account object by using the GetObject function and the LDAP provider.

  2. Use the SetPassword method to set the user accounts password to the specified value.

Listing 7.2 Setting a User Account Password

  
1
2
3


Set objUser = GetObject _
 ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
objUser.SetPassword "i5A2sj*!"

After the user account is enabled, a user can log on as MyerKen in the na.fabrikam.com domain with the password i5A2sj*!. The password is case sensitive when the user logs on from a computer running a Windows NTbased operating system but is not case sensitive when the user logs on from computers running other Windows operating systems, such as Windows 98. For Windows NTbased computers, a password of PASSWORD is not the same as a password of password.

Tip

  • Listing 7.2 shows the basic script structure required to set a user account password. However, you can improve on this script by using the Arguments property of the Windows Script Host (WSH) WScript object to receive parameters, such as the user account name and the OU where the user account resides. For more information about using the Arguments property, see "WSH Primer" in this book.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.