Below is the sample vbscript to set password for Users in Active Directory
'First connect to container (OU) under which we will create user TempUserName="TempUser" Set objUser = GetObject("LDAP://cn=TempUserName,OU=TestOU,DC=TEST,DC=COM")
objUser.SetPassword "Testme123"
'Also set password never expires
objUser.Put "PasswordExpired", CLng(1)
objUser.SetInfo
Wscript.echo "Sucessfully Set password for user TempUser" |
---|
Code above connects to the active directory object with CN=TempUser, ( connects to user TempUser) under TestOU, domain Test.com. The SetPassword will set the provided password for user and additionally we can set Password Never expires flag for that user.
No comments:
Post a Comment