manupug
-
Total Posts
:
14
- Scores: 0
-
Reward points
:
0
- Joined: 5/19/2009
-
Status: offline
|
How do call a vbscript from an ASP web page?
Tuesday, October 13, 2009 8:44 AM
( permalink)
Hello, I'm trying to create a web page in ASP that calls a VBScript. I followed the examples that I found in w3school.com, and everything works fine for simple output like "Hello world". When I try to run the actual script that I need nothing happens, only "Hello world" pops up. What do I need to implement to make this work? I thought that the problem was a directories issue, so I tried to move the webpage.asp around and then I realized that it needs to be under the wwwroot/myfolder. Any ideas? this is the web page as it is right now, it only outputs the Hello World message: <html> <body> <% response.write("Hello World!") %> <%On Error Resume Next REM Set Constants Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 REM Set Parameters Set objArgs = WScript.Arguments interactive = 0 bulk = 1 If WScript.arguments.count <> 4 Then interactive = 1 REM Prompt for input OUTPUT_CSVFILE=InputBox("Enter output CSV file:",wscript.scriptname,"..\data\active_students.csv") If OUTPUT_CSVFILE = "" Then Wscript.echo("Process Cancelled") WScript.Quit 0 End If DOMAIN=InputBox("Enter domain: ",wscript.scriptname,"ad.byuh.edu") If DOMAIN = "" Then Wscript.echo("Process Cancelled") WScript.Quit 0 End If DOMAIN_CRED=InputBox("Enter domain user: ",wscript.scriptname,"ad\mailman") If DOMAIN_CRED = "" Then Wscript.echo("Process Cancelled") WScript.Quit 0 End If DOMAIN_CRED_PASS=InputBox("Enter domain password: " & VbCrLf & "Default is mailman password",wscript.scriptname,"") If DOMAIN_CRED_PASS = "" Then DOMAIN_CRED_PASS = "Ma1lL1sT" End If DISTINCT_USER=InputBox("Enter Net ID if you want to process individual student, otherwise leave blank: ",wscript.scriptname,"") If DISTINCT_USER <> "" Then bulk = 0 End If Else OUTPUT_CSVFILE=objArgs.Item(0) DOMAIN=objArgs.Item(1) DOMAIN_CRED=objArgs.Item(2) DOMAIN_CRED_PASS=objArgs.Item(3) End If REM Setup & Initialze LDAP connection Set objDSE = GetObject("LDAP://" & DOMAIN & "/rootDSE") Set objLDAP = GetObject("LDAP:") If bulk = 1 Then byuhRDN = "OU=active,OU=people," & objDSE.Get("defaultNamingContext") Else byuhRDN = "CN=" & DISTINCT_USER & ",OU=active,OU=people," & objDSE.Get("defaultNamingContext") End If REM Delete output file if already exists Set objFile = CreateObject("Scripting.FileSystemObject") If objFile.FileExists(OUTPUT_CSVFILE) Then objFile.DeleteFile OUTPUT_CSVFILE End If Set objFile = nothing ' Initialize Regular Expression for finding Email Address alias Set re = new regexp 'Create the RegExp object Set re2 = new regexp re.Pattern = ".+\..+@byuh\.edu$" re2.Pattern = "^SMTP:(.+)$" re.IgnoreCase = true re2.IgnoreCase = true re.Global = true re2.Global = true Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Properties("User ID") = DOMAIN_CRED objConnection.Properties("Password") = DOMAIN_CRED_PASS objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection objCommand.Properties("Page Size") = 1000000 objCommand.CommandText = _ "<LDAP://" & DOMAIN & "/" & byuhRDN & ">;(&(objectCategory=inetorgperson)" & _ "(studentFLAG=TRUE)(proxyAddresses=*.*@byuh.edu)(!(employeeFLAG=TRUE))(!(businessCategory=OutlookLive-Mailbox)));distinguishedName,mail,cn,displayname,proxyAddresses,givenname,sn,employeenumber;Subtree" Set objRecordSet = objCommand.Execute intRecordCount = objRecordset.RecordCount If intRecordCount <> 0 Then REM Initialize and setup file objects set fs=CreateObject("Scripting.FileSystemObject") set f=fs.OpenTextFile(OUTPUT_CSVFILE,ForWriting,True) f.WriteLine("Action,Type,Name,EmailAddress,EmailAddress2,EmailAddress3,FirstName,LastName,DisplayName,Password,ForceChangePassword") objRecordSet.MoveFirst For intCounter = 1 To intRecordCount strProxyAddresses = objRecordSet.Fields("proxyAddresses") emailAddressPrimary = "" For Each Item in strProxyAddresses inputstr = Item 'Check to see if the address is a valid firstname.lastname@byuh.edu alias If (re.Test(inputstr)) Then 'WScript.Echo "This is an alias byuh address" Set byuhmatch = re2.Execute(inputstr) If byuhmatch.count > 0 Then emailAddressPrimary = byuhmatch.Item(0).SubMatches(0) Else emailAddressPrimary = inputstr End If End If Next If emailAddressPrimary <> "" Then f.WriteLine("Add,Mailbox," & TRIM(objRecordSet.Fields("cn").value) & "," & TRIM(emailAddressPrimary) & "," & TRIM(objRecordSet.Fields("cn").Value) & "@byuh.edu" & "," & TRIM(objRecordSet.Fields("cn").Value) & "@go.byuh.edu" & "," & TRIM(objRecordSet.Fields("givenname").value) & "," & TRIM(objRecordSet.Fields("sn").value) & "," & TRIM(objRecordSet.Fields("displayname").value) & "," & TRIM(objRecordSet.Fields("employeenumber").value) & ",1") End If objRecordSet.MoveNext Next f.Close set f=Nothing set fs=Nothing If interactive = 1 Then Wscript.echo("Process Done") End If Else REM Nothing To Process If interactive = 1 Then Wscript.echo("Nothing to process") End If End If%>
Errare humanum est, sed perseverare diabolicum! Si vis pacem, para bellum!
|