Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


VBScript Error in HTML

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3350
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VBScript Error in HTML
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 VBScript Error in HTML - 6/13/2005 7:27:38 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
I am getting an error on the GetObject in this code. Can I not do this from an HTML or HTA?

The error number is 80005008.
'=========================================================

<script language="vbscript">
Sub CreateAccount

Const ADS_UF_ACCOUNTDISABLE = 2
Const ADS_PROPERTY_UPDATE = 2

strUser = TextBox0.Value
If strUser = "" Then
MsgBox "You're missing required fields.",64, "Alert"
Exit Sub
End If

strFirst = TextBox1.Value
If strFirst = "" Then
MsgBox "You're missing required fields",64, "Alert"
Exit Sub
End If

strInitial = TextBox2.Value

strLast = TextBox3.Value
If strLast = "" Then
MsgBox "You're missing required fields",64, "Alert"
Exit Sub
End If

strDisplay = strLast & ", " & strFirst

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText = _
"<GC://dc=mlnusa,dc=com>;(&(objectCategory=Person)(objectClass=user)" & _
"(samAccountName=" & strUser & "));samAccountName;subtree"

Set objRecordSet = objCommand.Execute

If objRecordSet.RecordCount = 0 Then

Else
MsgBox "The User Account already exists.",48,"Alert"
Exit Sub
End If

objConnection.Close

Set objOU = GetObject("LDAP://OU=Test Users,OU=Test All Users,OU=Testing OU,DC=domain,DC=com") <-- ERROR HERE
Set objUser = objOU.Create("User", "cn=" & strUser)
objUser.Put "sAMAccountName", LCase(strUser)
objUser.SetInfo

objUser.Put "givenName", strFirst
objUser.Put "initials", strInitial
objUser.Put "sn", strLast
objUser.Put "displayName", strDisplay

objUser.SetPassword "password"
objUser.Put "pwdLastSet", 0

intUAC = objUser.Get("userAccountControl")
If intUAC And ADS_UF_ACCOUNTDISABLE Then
objUser.Put"userAccountControl", intUAC Xor ADS_UF_ACCOUNTDISABLE
objUser.SetInfo
End If

End Sub

</script>
 
 
Post #: 1
 
 Re: VBScript Error in HTML - 6/13/2005 7:41:32 AM   
  rockocubs

 

Posts: 65
Score: 0
Joined: 4/8/2005
From:
Status: offline
How are you passing your TextBox Values, i dont see them being passed to the Sub?

(in reply to esnmb)
 
 
Post #: 2
 
 Re: VBScript Error in HTML - 6/13/2005 7:51:20 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
They are coming in from Text boxes in the HTML page. Here is everything:

'============================================

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>User Account Creation Form</title>
<style type="text/css">
<!--
.style3 {font-size: 13px}
body,td,th {
font-family: Arial, Helvetica, sans-serif;
}
.style2 { font-family: Arial, Helvetica, sans-serif;
font-size: 13.5pt;
color: #CC6600;
font-weight: bold;
}
.style5 {font-size: small; color: #FF0000; }
.style6 {color: #FF0000}
-->
</style>
</head>
<script language="vbscript">
Sub CreateAccount

Const ADS_UF_ACCOUNTDISABLE = 2
Const ADS_PROPERTY_UPDATE = 2

strUser = TextBox0.Value
If strUser = "" Then
MsgBox "You're missing required fields.",64, "Alert"
Exit Sub
End If

strFirst = TextBox1.Value
If strFirst = "" Then
MsgBox "You're missing required fields",64, "Alert"
Exit Sub
End If

If strInitial = "" Then
Else
strInitial = TextBox2.Value
End If

strLast = TextBox3.Value
If strLast = "" Then
MsgBox "You're missing required fields",64, "Alert"
Exit Sub
End If

strDisplay = strLast & ", " & strFirst

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText = _
"<GC://dc=mlnusa,dc=com>;(&(objectCategory=Person)(objectClass=user)" & _
"(samAccountName=" & strUser & "));samAccountName;subtree"

Set objRecordSet = objCommand.Execute

If objRecordSet.RecordCount = 0 Then

Else
MsgBox "The User Account already exists.",48,"Alert"
Exit Sub
End If

objConnection.Close

Set objOU = GetObject("LDAP://OU=Test Users,OU=Test All Users,OU=Testing OU,DC=domain,DC=com")
Set objUser = objOU.Create("User", "cn=" & strUser)
objUser.Put "sAMAccountName", LCase(strUser)
objUser.SetInfo

objUser.Put "givenName", strFirst
objUser.Put "initials", strInitial
objUser.Put "sn", strLast
objUser.Put "displayName", strDisplay

objUser.SetPassword "password"
objUser.Put "pwdLastSet", 0

intUAC = objUser.Get("userAccountControl")
If intUAC And ADS_UF_ACCOUNTDISABLE Then
objUser.Put"userAccountControl", intUAC Xor ADS_UF_ACCOUNTDISABLE
objUser.SetInfo
End If

End Sub

</script>
<body>
<p><img src="Content/Images/logo.gif" width="189" height="46"></p>
<p class="style2">Account Creation Page.</p>
<table width="289" border="0" align="left">
<tr>
<td width="89"><span class="style5">*</span>Login ID: </td>
<td width="144"><input type="text" name="textbox0"></td>
</tr>
<tr>
<td><span class="style5">*</span>First Name:</td>
<td><input type="text" name="textbox1"></td>
</tr>
<tr>
<td>Middle Initial: </td>
<td><input type="text" name="textbox2"></td>
</tr>
<tr>
<td><span class="style5">*</span>Last Name: </td>
<td><input type="text" name="textbox3"></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p><br>
<input type="submit" name="Submit" value="Submit" onClick="CreateAccount">
</p>
<p>The login ID will have an initial password of password. </p>
<p>The new employee will also be requiered to change their password at next logon. </p>
<p class="style3"><span class="style6">*</span> Indicates Required Field</p>
</body>
</html>

(in reply to esnmb)
 
 
Post #: 3
 
 Re: VBScript Error in HTML - 6/13/2005 9:01:58 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
btw, this does work if I just run it as a vbs file...

(in reply to esnmb)
 
 
Post #: 4
 
 Re: VBScript Error in HTML - 6/13/2005 3:34:43 PM   
  TNO


Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Maybe this will help:

http://www.kbalertz.com/Feedback_841815.aspx

(in reply to esnmb)
 
 
Post #: 5
 
 Re: VBScript Error in HTML - 6/14/2005 12:42:47 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
I'm just trying to create a new user with no mailbox. I saw a bunch of code last night that showed this was possible, so I have to figure out why mine isn't working...

(in reply to esnmb)
 
 
Post #: 6
 
 Re: VBScript Error in HTML - 6/14/2005 2:08:01 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
I have it working as an HTA, so I am thinking that there is an issue with security...

(in reply to esnmb)
 
 
Post #: 7
 
 Re: VBScript Error in HTML - 6/14/2005 4:19:32 AM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
I ran everything under Windows 2000, without any error..........

<edit: euhm also with extension .HTML >

(in reply to esnmb)
 
 
Post #: 8
 
 Re: VBScript Error in HTML - 6/14/2005 5:15:13 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
hmmmm. I am lost then..

(in reply to esnmb)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VBScript Error in HTML Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts