Jump to content

creating mail enabled user accounts


Guest Colin Ashdown

Recommended Posts

Guest Colin Ashdown

Dear allI have been trying to create a user interface that creates new users with an external e mail address. I am a newbe when it comes to vb and I have learned through reading forums like this one. I have a script that is almost complete but I get errors when it tries to create the mail part.I am receiving an invalid Argument on line 79 - ID no : c103071f - Microsoft CDO for Exchange Management. Any help would be great.Kind RegardsColin-Script-<HTA:APPLICATION APPLICATIONNAME="User Account Creation Form v1.0" SCROLL="no" SINGLEINSTANCE="yes" WINDOWSTATE="normal" > <head> <title>User Account Creation Form v1.0</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> <script type="text/vbscript">Sub CreateAccount strUser = TextBox0.Value If strUser = "" Then MsgBox "You're missing required fields.",16, "Alert" Exit Sub End If strFirst = TextBox1.Value If strFirst = "" Then MsgBox "You're missing required fields",16, "Alert" Exit Sub End If strInitial = TextBox2.Value strLast = TextBox3.Value If strLast = "" Then MsgBox "You're missing required fields",16, "Alert" Exit Sub End If strPassword = TextBox11.Value If strPassword = "" Then MsgBox "You're missing required fields",16, "Alert" Exit Sub End If strTelephone = textbox4.ValuestrWebsite = textbox5.ValuestrJob = textbox6.ValuestrCompany = textbox7.Value'strManager = textbox8.valuestrDisplay = strFirst & ", " & strLast Const ADS_UF_ACCOUNTDISABLE = 2 Const ADS_PROPERTY_UPDATE = 2 Set objOU = GetObject("LDAP://OU=external_contacts,dc=quatermain,dc=local") Set objUser = objOU.Create("User", "cn=" & strUser) objUser.Put "sAMAccountName", LCase(strUser) objUser.Put "userPrincipalName", strUser & "@quatermain.local" 'set objUser = GetObject("LDAP://OU=external_contacts,dc=quatermain,dc=local", "user","cn" & strUser)objUser.MailEnable strEmailAddrobjUser.Put "internetEncoding",1310720objUser.SetInfo()objUser.SetInfo objUser.Put "givenName", strFirst If StrTelephone <> "" ThenobjUser.Put "telephoneNumber", strTelephoneEnd IfIf StrJob <> "" ThenobjUser.Put "title", strJobEnd IfIf strWebsite <> "" ThenobjUser.Put "wWWHomePage", strWebsiteEnd IfIf strCompany <> "" ThenobjUser.Put "company", strCompanyEnd IfIf strInitial <> "" Then objUser.Put "initials", strInitial End If'If strManager <> "" Then 'objUser.Put "manager", strManager 'End If objUser.Put "sn", strLast objUser.Put "displayName", strDisplayobjUser.SetPassword , strPassword objUser.Put "pwdLastSet", 0 intUAC = objUser.Get("userAccountControl") If intUAC And ADS_UF_ACCOUNTDISABLE Then objUser.Put"userAccountControl", intUAC Xor ADS_UF_ACCOUNTDISABLE End If objUser.SetInfo End Sub Sub Reload Location.Reload(True) End Sub Sub bodyLoaded() window.ResizeTo 600,510 ' WIDTH, HEIGHT End Sub ' ## Closes page on pressing [Exit] ## Sub CloseForm Window.Close End Sub 'CloseForm Sub About() On Error Resume Next strAbout="User Account Creation Form v1.0" & VbCrLf strAbout= strAbout & "____________________________" & vbTab & VbCrLf & VbCrLf strAbout=strAbout & " Quatermain Consultancy" & VbCrLf & VbCrLf strAbout=strAbout & " Author: Colin Ashdown" & VbCrLf strAbout=strAbout & " Date: 15 August 2006" & vbcrlf & vbcrlf strAbout= strAbout & "____________________________" & VbCrLf & VbCrLf MsgBox strAbout,vbOKOnly+vbInformation,"About" End Sub</script><body bgcolor="#00FFFF"> <!-- Start Of Main Table --> <table width="710" border="0" cellspacing="0" CellSpacing="0"> <tr><td width="350" Valign="top"> <!-- LHS Of Main Table --> <table border="0" cellspacing="0" CellSpacing="0"> <tr><td width="350"> <!-- Username/Shortcode --> <table border="0" cellspacing="0" CellSpacing="0" width="350"> <tr><td valign="top" colspan="3"><fieldset><legend><font face="Trebuchet MS"><b>User Settings</b></font></legend> <table border="0" cellpadding="3" width="350"> <tr><td width="110"><font size="2" face="Trebuchet MS">User Name</font>:</td><td> <font face="Trebuchet MS"><input type="text" name="textbox0" size="26"></font></td><td> <font face="Arial" color="#FF0000">*</font></td></tr> <tr><td><font size="2" face="Trebuchet MS">First Name</font>: </td><td> <font face="Trebuchet MS"><input type="text" name="textbox1" size="26"></font></td> <td width="59"><font face="Arial" color="#FF0000">*</font></td></tr> <tr><td><font size="2" face="Trebuchet MS">Middle Initial</font>: </td><td> <font face="Trebuchet MS"><input type="text" name="textbox2" size="26"></font></td> <td><font size="2" face="Trebuchet MS">(Optional)</font></td></tr> <tr><td><font size="2" face="Trebuchet MS">Last Name</font>: </td><td> <font face="Trebuchet MS"><input type="text" name="textbox3" size="26"></font></td><td> <font face="Arial" color="#FF0000">*</font></td></tr> </table><p></fieldset></table> <!-- End of Username/Shortcode --> <!-- User Account Properties --> <table border="0" cellpadding="0" cellspacing="0" width="350"> <tr><td valign="top" colspan="3"><fieldset><legend><b>User Account Properties</b></legend> <table border="0" cellpadding="3" width="350"> <tr> <td width="110">Telephone No:</td><td><font face="Trebuchet MS"><input name="textbox4" size="26" style="float: right"></font></td><td> </td> </tr> <tr><td>Web Site :</td> <td align="right"> <font face="Trebuchet MS"><input type="text" name="textbox5" size="26"></font></td> <td> </td> </tr> <tr> <td>Job Title: </td><td><font face="Trebuchet MS"><input name="textbox6" size="26" style="float: right"></font></td><td width="50"> </td> </tr> <tr> <td>Company: </td><td><input name="textbox7" size="26" style=" float:right"></td><td> </td> </tr> </table></fieldset></table> <!-- End of User Account Properties --> <!-- Group Membership --> <table border="0" cellspacing="0" CellSpacing="0" width="350"> <tr> <td valign="top" colspan="3"><fieldset><legend><b>Blank</b></legend> <table border="0" cellpadding="3" width="350"> <tr> <td width="150"> </td><td width="200" align="middle"> </td> </tr> <tr> <td width="150"> </td><td width="200" align="middle"> </td> </tr> <tr> <td width="150"> </td><td width="200" align="middle"> </td> </tr> </table></fieldset></table> <!-- End of Group Membership --> <!-- End of LHS Of Main Table --> </td></tr></table> </td> <td width="350" Valign="top"> <!-- RHS Of Main Table --> <table border="0" cellspacing="0" CellSpacing="0"> <tr><td width="350"> <!-- Create User Mail Account --> <table border="0" cellspacing="0" CellSpacing="0" width="350"> <tr><td valign="top" colspan="3"><fieldset><legend><font face="Trebuchet MS"><b>User Mail Account</b></font></legend> <table border="0" cellpadding="3" width="345"> <tr> <td width="300"> </td><td width="41" align="middle"> </td> </tr></table> <table border="0" cellpadding="3" width="350"> <tr> <td width="125"><font size="2" face="Trebuchet MS">E Mail Address:</font> </td> <td align="right"><p align="center"> <font face="Trebuchet MS"><input type="text" name="textbox10" size="26"></font><font face="Arial" color="#FF0000">  *</font></td> </tr> </table></fieldset></table> <!-- End of Create User Mailbox --> <!-- Add to Distribution Lists --> <table border="0" cellspacing="0" CellSpacing="0" width="350"> <tr><td valign="top" colspan="3"><fieldset><legend><b>Password</b></legend> <table border="0" width="100%" id="table1"> <tr> <td width="126"><font face="Trebuchet MS" size="2">Set Password:</font></td> <td> <font face="Trebuchet MS"> <input type="text" name="textbox11" size="26" value="pa55w0rd"> </font><font face="Arial" color="#FF0000"> *</font></td> </tr> <tr> <td width="126"> </td> <td> </td> </tr> </table> </fieldset></table> <!-- End of Add to Distribution Lists --> <!-- Create User Home Directory --> <table border="0" cellspacing="0" CellSpacing="0" width="350"> <tr><td valign="top" colspan="3"><fieldset><legend><b>Notes</b></legend> <table border="0" cellpadding="3" width="350"> <tr> <td width="300"> </td><td width="50" align="middle">  </td></tr> </table><p></fieldset></table> <!-- End Of Create User Home Directory --> <!-- Enable Logging --> <table border="0" cellspacing="0" CellSpacing="0" width="350"> <tr><td valign="top" colspan="3"><fieldset><legend><b>Blank</b></legend> <table border="0" cellpadding="3" width="350"> <tr> <td width="300"> </td><td width="50" align="middle">  </td></tr> </table><p></fieldset></table> <!-- End Of Enable Logging --> <table border="0" cellspacing="0" cellpadding="0" width="350" height="147"> <tr> <td valign="top"> <!-- Blank Table for future additions/features -->  <b>NOTE:</b> Items marked with <font size="3" color="red"><b>*</b></font> are mandatory fields</td></tr> </table> <table border="0" cellspacing="0" cellpadding="0" width="350"> <tr> <td align="right" valign="bottom"> <input type="button" value=" About " onclick="About"> <input type="button" value="Clear Form" onclick="Reload" title=" Click to Clear Form "> <input type="button" value=" Submit " onClick="CreateAccount" title=" Click to Create User Account "> <input type="button" value=" Exit " onclick="CloseForm" title=" Click to Exit Form "> </td></tr> </table> <!-- End of RHS Of Main Table --> </td></tr></table> </td></tr></table> <!-- End Of Main Table --> </body> </html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...