• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Question about scripting

BZeto

Platinum Member
Say for example I have a script to set a specific user account expiration date in active directory. Only i don't wan't the expiration date to be the same each time I run the script and I don't want to manually edit the script to change the expiration date.

How difficult would it be to write some sort of tool with a blank field I can type the date into and then it automatically plugs that into my script and runs it?

Thanks
 
Assuming it's vbscript, there should be a section of code that sets a variable to a specific date which is later used during the setting of the expiration date. Look for where that variable is set, and instead of hard coding the value, change it to the following:

variable = InputBox("Enter Expiration Date", "Prompt", , 200, 200)

The first parameter is the text in the message box, second is the title of the msg box, third is blank, 4th is the width and 5th is the height.
 
Hmm, well here is my exact code:

Set objUser = GetObject _
("LDAP://cn=testaccount,dc=domain,dc=com")

objUser.AccountExpirationDate = "02/11/2009"
objUser.SetInfo


So I could put your line of code in place of my date? I'm not sure I really understand the variable thing.
 
variable is simply assigned whatever string you entered in the InputBox. not sure how picky the formatting is, but you probably want to do some syntax checking as well. this should include blank variable strings and misformatted dates...
 
As jlazzaro said, the variable is just a temporary holding spot for a value which can later be used. It's not necessary in your script. Change the script to read the following:

Set objUser = GetObject _
("LDAP://cn=testaccount,dc=domain,dc=com")

objUser.AccountExpirationDate = InputBox("Enter Expiration Date", "Prompt", , 200, 200)
objUser.SetInfo


If someone other than you will be using the script, I would recommend the checks as well, but if only you will be using it, and you trust yourself enough to not screw up the date format, you'll be fine without it.
 
Back
Top