[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 611
  • Last Modified:

Perplexed by Type mismatch: 'return' Error

I made a little HTA application a few months back that simplifies the Active Directory account creation process. I honestly cannot recall ever testing it on any computer besides my own when I made it.  A few days ago, someone else in IT attempted to use the HTA and they had a problem.  It opened fine, but when they hit the drop-down box that lets you select the new user's job title, they received an Internet Explorer script error, which I have attached here.  The application works fine on my computer, but that seems to be the only one.  I have tested on several other machines, but receive the same error wherever I test it.  I'm not sure what to check here to figure out what the heck is causing the issue.  I have also attached all the code below.  I appreciate any assistance.

<html> 
<HTA:APPLICATION 
APPLICATIONNAME="Domain AD Account Creation" 
SCROLL="no" 
SINGLEINSTANCE="yes" 
WINDOWSTATE="normal" 
> 
<head> 
<title>Domain User Account Creation Form</title> 
<style type="text/css"> 
    <!-- 
body,td,th {
        font-family: Arial, Helvetica, sans-serif;
        background-color: #FFFFFF;
    } 
.style2 { font-family: Arial, Helvetica, sans-serif; 
font-size: 13.5pt; 
color: #FF0000; 
font-weight: bold; 
} 
    #Select1
    {
        width: 167px;
    }
    #jobtitle
    {
        width: 220px;
    }
--> 
</style> 
 
<script type="text/vbscript"> 
 
'This section is the error reporting for the application 
 
Sub CreateAccount 
Dim strFinitial
Dim strFirst
Dim strLast
Dim strPassword
Dim strDisplay
Dim strCN
Dim strUser
Dim strTitle
Dim objFolder
Dim objObject
 
strFinitial = TextBox1.Value 
If strFinitial = "" Then 
MsgBox "You're missing required fields - First Initial",64, "Alert" 
Exit Sub 
End If 
 
strFirst = TextBox2.Value 
If strFirst = "" Then 
MsgBox "You're missing required fields - First Name",64, "Alert" 
Exit Sub 
End If 
 
strLast = TextBox3.Value 
If strLast = "" Then 
MsgBox "You're missing required fields - Last Name",64, "Alert" 
Exit Sub 
End If 
 
strPassword = TextBox4.Value 
If strPassword = "" Then 
MsgBox "You're missing required fields - Password",64, "Alert" 
Exit Sub 
End If
 
strTitle = JobTitle.Value 
If strTitle = "" Then 
MsgBox "You're missing required fields - Job Title",64, "Alert" 
Exit Sub 
End If  
 
strDisplay = strFirst & " " & strLast 
strCN = strFirst & " " & strLast 
strUser = strFinitial & "" & strLast
 
Const ADS_UF_ACCOUNTDISABLE = 2 
Const ADS_PROPERTY_UPDATE = 2 
        
' This section will create the user & set part of the General Page. 
On Error Resume Next
Set objOU = GetObject("LDAP://CN=Users,DC=mydomainname,DC=com") 
 
If Err Then AdsiErr("Setting objOU")
err.clear
'On Error GoTo Handler
 
Set objUser = objOU.Create("User", "cn=" & strCN) 
 
If Err Then AdsiErr("Setting objUser")
err.clear   
'On Error GoTo Handler
 
objUser.Put "sAMAccountName", LCase(strUser) 
objUser.Put "userPrincipalName", strUser & "@mydomainname.com" 
objUser.Put "givenName", strFirst 
objUser.Put "sn", strLast
objUser.Put "company", "My Company"
objUser.Put "countryCode", "840" 
objUser.Put "c", "US"
objUser.Put "displayName", strDisplay
objUser.Put "title", strTitle 
objUser.SetInfo
  
If Err Then AdsiErr("Putting user details in AD")
err.clear
 
Const ADS_UF_NORMAL_ACCOUNT = 512
objUser.Put "userAccountControl", ADS_UF_NORMAL_ACCOUNT
 
If Err Then AdsiErr("Setting user account control")
err.clear
 
objUser.SetPassword(strPassword)
'objUser.accountdisabled = False
objUser.SetInfo
 
If Err Then AdsiErr("Setting password")
err.clear
 
'This Section Will Add the user to the Employees Group 
Const ADS_PROPERTY_APPEND = 3 
Set objGroup = GetObject("LDAP://cn=Employees,cn=Users,dc=mydomainname,dc=com") 
objGroup.PutEx ADS_PROPERTY_APPEND, "member", Array("cn=" & strCN & ",CN=Users,dc=mydomainname,dc=com") 
objGroup.SetInfo  
 
If Err Then AdsiErr("Putting user info in AD")
err.clear
 
' This section sets the login script 
objUser.Put "scriptPath", "script.vbs"
objUser.SetInfo
 
If Err Then AdsiErr("Setting login script")
err.clear
 
 
' This section sets the users home drive Information 
objUser.Put "homeDirectory", "\\server1\" & strUser
objUser.Put "homeDrive", "H:" 
objUser.SetInfo 
objUser.GetInfo
intUserFlags = objUser.Get("userAccountControl")
intNewUserFlags = intUserFlags Or UF_DONT_EXPIRE_PASSWD
objUser.Put "userAccountControl", intNewUSerFlags
objUser.SetInfo 
 
 If Err Then AdsiErr("Setting home drive info")
err.clear 
 
 
'This Section will Create The Users Home Drive on \\server1\Users
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objFolder = objFSO.CreateFolder("\\server1\f$\users\users\" & strUser)  
Set FservObj = GetObject("WinNT://MYDOMAIN/NT4/lanmanserver")
Set newshare = FservObj.create("fileshare",strUser)
newshare.path = "f:\users\users\" & strUser
newshare.Setinfo
 
If Err Then AdsiErr("Creating home drive")
err.clear
 
'This section sets share and NTFS permissions on the home directory
Set objShell = CreateObject("WScript.Shell") 
objShell.Run "XCACLS \\server1\f$\users\users\" & strUser & " /T /G mydomain\" & strUser & ":C ""mydomain\Domain Admins"":F /y",1 ,True
objShell.Run "SETACL -on \\server1\" & strUser & " -ot shr -actn ace -ace n:mydomain\" & strUser & ";p:change -ace n:""mydomain\Domain Admins"";p:full"
 
If Err Then AdsiErr("Setting permissions")
err.clear
 
' This section creates the Exchange mailbox
Set objOU = GetObject("LDAP://CN=" & strCN & ",CN=Users,DC=mydomainname,DC=com")
objUser.Put "HomeMDB", "CN=Mailbox Store (SERVER2),CN=First Storage Group,CN=InformationStore,CN=SERVER2,CN=Servers,CN=MYDOMAIN,CN=Administrative Groups,CN=MY DOMAIN,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=mydomainname,DC=com"
objUser.Put "mailnickname",strUser
objUser.Put "mDBUseDefaults", TRUE
objUser.Put "mail",strUser & "@mydomainname.com"
objUser.SetInfo
 
If Err Then AdsiErr("Creating mailbox")
err.clear
 
 
' This section sets the Communication server stuff
Set objUser = GetObject("LDAP://CN=" & strCN & ",CN=Users,DC=mydomainname,DC=com")
strPrimaryUserAddress = "sip:" & objUser.get("mail")
nArchivingEnabled = 0
nOptionFlags = 256
strPrimaryHomeServer = "CN=LC Services,CN=Microsoft,CN=SERVER3,CN=Pools,CN=RTC Service,CN=Microsoft,CN=System,DC=mydomainname,DC=com"
objUser.put "msRTCSIP-PrimaryUserAddress", strPrimaryUserAddress
objUser.put "msRTCSIP-ArchivingEnabled", nArchivingEnabled
objUser.put "msRTCSIP-OptionFlags", nOptionFlags
objUser.put "msRTCSIP-PrimaryHomeServer", strPrimaryHomeServer
objUser.put "msRTCSIP-UserEnabled", True
objUser.setinfo
 
If Err Then AdsiErr("Setting communication server info")
err.clear
 
 
' The end notification message
MsgBox "User has been created" & vbNewLine & "Employee Name: " & strCN & vbNewLine & "Username: " & strUser & vbNewLine & "Job Title: " & strTitle & vbNewLine & "Home Directory Created and Shared" & vbNewLine & "Exchange Mailbox Created" & vbNewLine & "Communication Server Enabled",64, "Alert" 
End Sub
 
Sub AdsiErr(strErrorInSection)
'AdsiErr()
        Dim s
        Dim e
 
        If Err.Number = &H800708B0 Then
                MsgBox "The user " & strUser & " already exists." & vbCRLF & strErrorInSection,64, "Alert"  
        Elseif Err.Number = &H80070035 Then
                MsgBox "Computer not found.  Check the ADsPath and try again" & vbCRLF & strErrorInSection,64, "Alert"
        Elseif Err.Number = "-2147022672" Then
                MsgBox "UserID already exists." & vbCRLF & strErrorInSection,64, "Alert"
        Else
        e = Hex(Err.Number)
                MsgBox "Unexpected Error " & e & "(" & Err.Number & ")" & vbCRLF & strErrorInSection,64, "Alert"
        End If
        'WScript.Quit
 
End Sub
 
Sub Reload 
 
location.Reload(True) 
End Sub 
 
Sub bodyLoaded() 
 
window.ResizeTo 510,545 ' WIDTH, HEIGHT 
 
End Sub 
 
</script> 
<script language="javascript" type="text/javascript">
// <!CDATA[
 
    function Select1_onclick() {
 
    }
 
// ]]>
</script>
</head> 
<body onLoad="bodyLoaded()"> 
<p align="center"><img src="tech.jpg" style="height: 142px; width: 136px"></p> 
<p class="style2" align="left"> Tech<font color="#FF0000"> </font>Domain User Account Creation Form<font color="#FF0000">            &nbsp 
<table border="0" align="left" height="59" style="width: 352px"> 
<tr> 
<td width="94" height="14">First Initial:</td> 
<td width="173" height="14"><input type="text" name="textbox1" size="1" 
        maxlength="2" style="width: 20px"></td> 
</tr> 
<tr> 
<td width="94" height="14">First Name:</td> 
<td width="173" height="14"><input type="text" name="textbox2" size="23" 
        style="width: 220px"></td>  
</tr> 
<tr> 
<td width="94" height="14">Last Name: </td> 
<td width="173" height="14"><input type="text" name="textbox3" size="23" 
        style="width: 220px"></td>
</tr> 
<tr> 
<td width="94" height="14">Job Title:</td> 
<td width="173" height="14">
    <select name="jobtitle" onclick="return Select1_onclick()" style="width: 220px">
        <option value=" "> </option>
        <option value="Assistant Project Manager">Assistant Project Manager</option>
        <option value="Assistant Site Manager">Assistant Site Manager</option>
        <option value="Assistant Site Manager Trainee">Assistant Site Manager Trainee</option>
        <option value="Carpenter">Carpenter</option>
        <option value="Contracts Manager">Contracts Manager</option>
        <option value="Estimator">Estimator</option>
        <option value="Executive Assistant">Executive Assistant</option>
        <option value="Field Administrative Assistant">Field Administrative Assistant</option>
        <option value="Field Office Manager">Field Office Manager</option>
        <option value="Project Accountant">Project Accountant</option>
        <option value="Project Engineer">Project Engineer</option>
        <option value="Project Manager">Project Manager</option>
        <option value="Senior Estimator">Senior Estimator</option>
        <option value="Senior Project Manager">Senior Project Manager</option>
        <option value="Site Manager">Site Manager</option>
        <option value="Superintendent">Superintendent</option>
    </select></td>
</tr> 
<tr> 
<td width="94" height="14">Password: </td> 
<td width="173" height="14"><input type="text" name="textbox4" size="23" 
        style="width: 220px"></td> 
</table> 
 
<br> 
<br> 
<br> 
<br> 
<p> 
<br> 
<br> 
<br> 
</p> 
<p> 
<input type="button" name="Submit" value="Submit" onClick="CreateAccount"> 
</p> 
<p>
<input id="reloadbutton" class="button" type="reset" value="Clear Form" name="reload_button" onClick="Reload">                                        <font </p> 
<p> 
<input type="button" value=" Exit " name="close_button" onClick="Self.Close"> 
</p> 
</body> 
</html>

Open in new window

0
HarkinsIT
Asked:
HarkinsIT
  • 2
  • 2
1 Solution
 
HarkinsITAuthor Commented:
Whoops.  Here's the error message.

Thanks
error.jpg
0
 
EverLearningCodeMonkeyCommented:
Hi HarkinsIT,

Just from taking a quick look through your code - I'm wondering what the call to Select1_onclick() in the select box on line 272 is for - the function is empty and doesn't seem to serve any purpose.  It was probably added automatically by whatever IDE you were using.

Remove the onclick call and I imagine that this problem will disappear.

Hope this helps,

ELCM
0
 
HarkinsITAuthor Commented:
Dang.  Rookie mistake.  That did the trick.  Thanks very much!
0
 
EverLearningCodeMonkeyCommented:
No problem,

Glad to be of help.

ELCM
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now