Login | |
|
 |
Re: Create User Script - 6/28/2005 9:52:43 PM
|
|
 |
|
| |
cjwallace
Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
|
That worked a treat. Thanks very much the script now runs through. I have a small issue. I would like the user principalname to automatically put in the users username in before the @withers.net Set objOU = GetObject("LDAP://OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") Set objUser = objOU.Create("User", "cn=" & strUser) objUser.Put "sAMAccountName", LCase(strUser) objUser.Put "userPrincipalName", "@withers.net" objUser.SetInfo This is the whole code so far. <html> <HTA:APPLICATION APPLICATIONNAME="Account Creation" SCROLL="no" SINGLEINSTANCE="yes" WINDOWSTATE="normal" > <head> <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> <script type="text/vbscript"> Sub CreateAccount 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 = strFirst & ", " & strLast Const ADS_UF_ACCOUNTDISABLE = 2 Const ADS_PROPERTY_UPDATE = 2 Set objOU = GetObject("LDAP://OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") Set objUser = objOU.Create("User", "cn=" & strUser) objUser.Put "sAMAccountName", LCase(strUser) objUser.Put "userPrincipalName", "@withers.net" objUser.SetInfo objUser.Put "givenName", strFirst If strInitial <> "" Then objUser.Put "initials", strInitial End If objUser.Put "sn", strLast objUser.Put "displayName", strDisplay objUser.SetPassword "Passw0rd" 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 </script> </head> <body onLoad="bodyLoaded()"> <p><img src="/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="button" 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 first logon. </p> <p class="style3"><span class="style6">*</span> Indicates Required Field</p> <p> <input id="reloadbutton" class="button" type="reset" value="Clear Form" name="reload_button" onClick="Reload"> </p> <p> <input type="button" value=" Exit " name="close_button" onClick="Self.Close"> </p> </body> </html>
|
|
| |
|
|
|
 |
Re: Create User Script - 6/29/2005 4:09:06 AM
|
|
 |
|
| |
cjwallace
Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
|
Ok my next issue is this. i have put "cn=" & strUser in to ("LDAP://"cn=" & strUser,OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") but when run it i get Line: 93 Char: 15 Error: Expected ')' I have put a ) all over the place trying to get it to work but it wont take it. Any ideas as what i am doing wrong? ' Address Page Information Set objUser = GetObject _ ("LDAP://"cn=" & strUser,OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objUser.Put "streetAddress", "16 STREET ADDRESS" objUser.Put "l", "London" objUser.Put "postalCode", "POST CODE" objUser.Put "c", "GB" objUser.SetInfo Many thanks for your help
|
|
| |
|
|
|
|
|