How to set password for users in Active Directory through vbscript



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

Golang: Http POST Request with JSON Body example

Go standard library comes with "net/http" package which has excellent support for HTTP Client and Server.   In order to post JSON ...