Login | |
|
 |
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>
|
|
| |
|
|
|
 |
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>
|
|
| |
|
|
|
 |
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 >
|
|
| |
|
|
|
|
|