Password Control can be extended by adding VBS script files in the “Scripts” folder of the Password Control application directory. These Scripts will appear in a “Tools” menu in the Password Control application.
Example 1 – Adding a “Delete User” option
In this example we will write a VBS Script to delete the selected user account in Password Control. Password Control will enumerate all the VBS files in the “Scripts” folder and display them as options in the tools menu. Password Control will pass the ADsPath of the current user to the script, allowing us to know which user is currently selected.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
ADsPath = wscript.arguments.named.item("ADsPath") ' Validate that a user was selected if ADsPath = "" then msgbox "Please type the name of the user to delete in the Password Control username textbox",vbOkOnly+vbExclamation,"Username required" wscript.quit end if ' Bind to the user object set objUser = getobject(ADsPath) ' Confirm that the user account is to be deleted result = msgbox("Are you sure you want to delete this user account?" & vbcrlf & _ objUser.sAMAccountName,vbyesno+vbExclamation,"Confirm Delete") if result = vbYes then ' Bind to the container object (organizational unit) set objContainer = getobject(objUser.Parent) ' Delete the user account objContainer.Delete "user","cn=" & objUser.cn msgbox "User account deleted successfully",vbOkOnly+vbInformation end if |
Example 2 – Adding a shortcut to Active Directory Users and Computers
In this example we don’t need to verify if a valid user has been selected in Password Control.
1 2 3 |
set objShell = createobject("Wscript.Shell") ' Run Active Directory Users & Computers MMC objShell.Run "dsa.msc" |