I have a script that I have written with much assistance from this forum that creates new user accts on the Active Directory. I have decided however that rather than have a series of input boxes to collect information about the new user I would use a web type form. My question is, can anybody advise me on how to pass information from the form to the rest of the script? So that basically whatever was input on the form would be passed as a variable to the rest of the script. The initial form that I have written reads as follows:
set objexplorer = createobject("internetexplorer.application")
objexplorer.navigate2 "about:blank" : objexplorer.width = 650 : objexplorer.height = 350 : objexplorer.toolbar = false : objexplorer.menubar = false : objexplorer.statusbar = false : objexplorer.visible = True
objexplorer.document.write "<font color=blue>"
objexplorer.document.write "<h2>User Account Creation Tool</h2>"
objexplorer.document.write "<table border=" &chr34 & "3" &chr34 & ">"
objexplorer.document.write "<tr>"
objexplorer.document.write " <th>User Name:</th>"
objexplorer.document.write " <td>First name: "
objexplorer.document.write "<input type=" &chr34 & "teoxt" &chr34 & " name=" &chr34 & "firstname" &chr34 & ">"
objexplorer.document.write "Last name:"
objexplorer.document.write "<input type=" &chr34 & "text" &chr34 & " name=" &chr34 & "lastname1" &chr34 & "><br></td>"
objexplorer.document.write "</tr>"
objexplorer.document.write "<tr>"
objexplorer.document.write " <th>Home Server</th>"
objexplorer.document.write " <td><select name=" &chr34 & "City" &chr34 & ">"
objexplorer.document.write "<option value=" &chr34 & "Site1" &chr34 & ">Site1"
objexplorer.document.write "<option value=" &chr34 & "Site2" &chr34 & ">Site2"
objexplorer.document.write "<option value=" &chr34 & "Site3" &chr34 & ">Site3"
objexplorer.document.write "</select></td>"
objexplorer.document.write "</tr>"
objexplorer.document.write "<tr>"
objexplorer.document.write " <th>E Mail Settings</th>"
objexplorer.document.write " <td>Mail Server:"
objexplorer.document.write "<select name=" &chr34 & "Server" &chr34 & ">"
objexplorer.document.write "<option value=" &chr34 & "Exchange-1" &chr34 & ">Exchange-1"
objexplorer.document.write "<option value=" &chr34 & "Exchange-2" &chr34 & ">Exchange-2"
objexplorer.document.write "<option value=" &chr34 & "Exchange-3" &chr34 & ">Exchange-3"
objexplorer.document.write "</select><br>"
objexplorer.document.write "Storage Group:"
objexplorer.document.write "<select name=" &chr34 & "strgroup" &chr34 & ">"
objexplorer.document.write "<option value=" &chr34 & "DB1" &chr34 & ">DB1"
objexplorer.document.write "<option value=" &chr34 & "DB2" &chr34 & ">DB2"
objexplorer.document.write "<option value=" &chr34 & "DB3" &chr34 & ">DB3"
objexplorer.document.write "<option value=" &chr34 & "DB4" &chr34 & ">DB4"
objexplorer.document.write "<option value=" &chr34 & "DB5" &chr34 & ">DB5"
objexplorer.document.write "</select></td>"
objexplorer.document.write "</tr>"
objexplorer.document.write "<tr>"
objexplorer.document.write " <th>Further Access</th>"
objexplorer.document.write " <td>"
objexplorer.document.write "<input type=" &chr34 & "checkbox" &chr34 & " name=" &chr34 & "visio" &chr34 & ">"
objexplorer.document.write "ms_visio2003"
objexplorer.document.write "<br>"
objexplorer.document.write "<input type=" &chr34 & "checkbox" &chr34 & " name=" &chr34 & "access" &chr34 & ">"
objexplorer.document.write "ms_access2002"
objexplorer.document.write "</td>"
objexplorer.document.write "</tr>"
objexplorer.document.write "</table>"
objexplorer.document.write "<br>"
objexplorer.document.write "<input type=" &chr34 & "button" &chr34 & " value=" &chr34 & "Create Account" &chr34 & " onclick=" &chr34 & ">"
objExplorer.document.title = "user Account creation Tool "
Then with a bit of magic in the middle the rest of the script would then follow:
lastname= UCase(lastname1)
initial = LCase(Left(firstName, 1))
initial2 = LCase(Left(firstName, 2))
username1 = LCase(left(lastName,6))
username = username1 & initial
bothName = firstName & " " & lastName
strdisplayname = lastname & " " & firstname & " -my company domain"
strdisplayname1 = lastname & ", " & firstname & " -my company domain"
dim strnames(7)
strnames(0)="OU= Site1 ,OU=XP Users,OU=City1,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(1)="OU= Site4,OU=XP Users,OU=City1,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(2)="OU= Site3,OU=XP Users,OU=City1,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(3)="OU= Site2,OU=XP Users,OU=City1,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(4)="OU= XP Users,OU=City1,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(5)="OU= Users,OU=City1,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(6)="OU= XP Users,OU=City5,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(7)="OU= Users,OU=City5,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
for i= 0 to 7
Set objDomain = GetObject("LDAP://" & strnames(i))
For Each objUser In objDomain
If UCase(objUser.sAMAccountName) = UCase(username) Then
'wscript.echo "Username : " & username & " is already being used in the Active Directory."
initial = LCase(Left(firstName, 2))
username1 = LCase(left(lastName,6))
username = username1 & initial
Exit For
End If
Next
next
wscript.echo "Your user has been given the following username: " & username
'This part of the script creates the user account on the server
set objParent = GetObject("LDAP://" & strldap)
set objUser = objParent.Create("user", "cn=" & strdisplayname)
objUser.Put "sAMAccountName", "" & username
objUser.Put "userPrincipalName", "" & username & "@domain.intra.my company.com"
objUser.Put "givenName", "" & firstname
objUser.Put "sn", "" & lastname1
objUser.Put "displayName", "" & strdisplayname1
objuser.Put "physicalDeliveryOfficeName", "" & stroffice
objuser.Put "Description" ,"New user: " & Date
objuser.Put "scriptPath", "pilot.syn"
objUser.TerminalServicesProfilePath = "\\" & strfshare & "\profiles.$\" & username & "\terminal"
objUser.mail = firstname & "." & lastname1 & "@my company.com"
objUser.SetInfo
objUser.SetPassword "password"
objUser.AccountDisabled = TRUE
objuser.setinfo
etc........
I have not been able to search the forum so far as the facility seems to be down so I apologise in advance if this is a simple problem that I should be able to solve myself
set objexplorer = createobject("internetexplorer.application")
objexplorer.navigate2 "about:blank" : objexplorer.width = 650 : objexplorer.height = 350 : objexplorer.toolbar = false : objexplorer.menubar = false : objexplorer.statusbar = false : objexplorer.visible = True
objexplorer.document.write "<font color=blue>"
objexplorer.document.write "<h2>User Account Creation Tool</h2>"
objexplorer.document.write "<table border=" &chr34 & "3" &chr34 & ">"
objexplorer.document.write "<tr>"
objexplorer.document.write " <th>User Name:</th>"
objexplorer.document.write " <td>First name: "
objexplorer.document.write "<input type=" &chr34 & "teoxt" &chr34 & " name=" &chr34 & "firstname" &chr34 & ">"
objexplorer.document.write "Last name:"
objexplorer.document.write "<input type=" &chr34 & "text" &chr34 & " name=" &chr34 & "lastname1" &chr34 & "><br></td>"
objexplorer.document.write "</tr>"
objexplorer.document.write "<tr>"
objexplorer.document.write " <th>Home Server</th>"
objexplorer.document.write " <td><select name=" &chr34 & "City" &chr34 & ">"
objexplorer.document.write "<option value=" &chr34 & "Site1" &chr34 & ">Site1"
objexplorer.document.write "<option value=" &chr34 & "Site2" &chr34 & ">Site2"
objexplorer.document.write "<option value=" &chr34 & "Site3" &chr34 & ">Site3"
objexplorer.document.write "</select></td>"
objexplorer.document.write "</tr>"
objexplorer.document.write "<tr>"
objexplorer.document.write " <th>E Mail Settings</th>"
objexplorer.document.write " <td>Mail Server:"
objexplorer.document.write "<select name=" &chr34 & "Server" &chr34 & ">"
objexplorer.document.write "<option value=" &chr34 & "Exchange-1" &chr34 & ">Exchange-1"
objexplorer.document.write "<option value=" &chr34 & "Exchange-2" &chr34 & ">Exchange-2"
objexplorer.document.write "<option value=" &chr34 & "Exchange-3" &chr34 & ">Exchange-3"
objexplorer.document.write "</select><br>"
objexplorer.document.write "Storage Group:"
objexplorer.document.write "<select name=" &chr34 & "strgroup" &chr34 & ">"
objexplorer.document.write "<option value=" &chr34 & "DB1" &chr34 & ">DB1"
objexplorer.document.write "<option value=" &chr34 & "DB2" &chr34 & ">DB2"
objexplorer.document.write "<option value=" &chr34 & "DB3" &chr34 & ">DB3"
objexplorer.document.write "<option value=" &chr34 & "DB4" &chr34 & ">DB4"
objexplorer.document.write "<option value=" &chr34 & "DB5" &chr34 & ">DB5"
objexplorer.document.write "</select></td>"
objexplorer.document.write "</tr>"
objexplorer.document.write "<tr>"
objexplorer.document.write " <th>Further Access</th>"
objexplorer.document.write " <td>"
objexplorer.document.write "<input type=" &chr34 & "checkbox" &chr34 & " name=" &chr34 & "visio" &chr34 & ">"
objexplorer.document.write "ms_visio2003"
objexplorer.document.write "<br>"
objexplorer.document.write "<input type=" &chr34 & "checkbox" &chr34 & " name=" &chr34 & "access" &chr34 & ">"
objexplorer.document.write "ms_access2002"
objexplorer.document.write "</td>"
objexplorer.document.write "</tr>"
objexplorer.document.write "</table>"
objexplorer.document.write "<br>"
objexplorer.document.write "<input type=" &chr34 & "button" &chr34 & " value=" &chr34 & "Create Account" &chr34 & " onclick=" &chr34 & ">"
objExplorer.document.title = "user Account creation Tool "
Then with a bit of magic in the middle the rest of the script would then follow:
lastname= UCase(lastname1)
initial = LCase(Left(firstName, 1))
initial2 = LCase(Left(firstName, 2))
username1 = LCase(left(lastName,6))
username = username1 & initial
bothName = firstName & " " & lastName
strdisplayname = lastname & " " & firstname & " -my company domain"
strdisplayname1 = lastname & ", " & firstname & " -my company domain"
dim strnames(7)
strnames(0)="OU= Site1 ,OU=XP Users,OU=City1,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(1)="OU= Site4,OU=XP Users,OU=City1,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(2)="OU= Site3,OU=XP Users,OU=City1,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(3)="OU= Site2,OU=XP Users,OU=City1,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(4)="OU= XP Users,OU=City1,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(5)="OU= Users,OU=City1,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(6)="OU= XP Users,OU=City5,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
strnames(7)="OU= Users,OU=City5,OU=Sites,DC=domain,DC=intra,DC=my company,DC=com"
for i= 0 to 7
Set objDomain = GetObject("LDAP://" & strnames(i))
For Each objUser In objDomain
If UCase(objUser.sAMAccountName) = UCase(username) Then
'wscript.echo "Username : " & username & " is already being used in the Active Directory."
initial = LCase(Left(firstName, 2))
username1 = LCase(left(lastName,6))
username = username1 & initial
Exit For
End If
Next
next
wscript.echo "Your user has been given the following username: " & username
'This part of the script creates the user account on the server
set objParent = GetObject("LDAP://" & strldap)
set objUser = objParent.Create("user", "cn=" & strdisplayname)
objUser.Put "sAMAccountName", "" & username
objUser.Put "userPrincipalName", "" & username & "@domain.intra.my company.com"
objUser.Put "givenName", "" & firstname
objUser.Put "sn", "" & lastname1
objUser.Put "displayName", "" & strdisplayname1
objuser.Put "physicalDeliveryOfficeName", "" & stroffice
objuser.Put "Description" ,"New user: " & Date
objuser.Put "scriptPath", "pilot.syn"
objUser.TerminalServicesProfilePath = "\\" & strfshare & "\profiles.$\" & username & "\terminal"
objUser.mail = firstname & "." & lastname1 & "@my company.com"
objUser.SetInfo
objUser.SetPassword "password"
objUser.AccountDisabled = TRUE
objuser.setinfo
etc........
I have not been able to search the forum so far as the facility seems to be down so I apologise in advance if this is a simple problem that I should be able to solve myself