Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RE: Re: Create User Script

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: Re: Create User Script
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  4 5 [6] 7 8   next >   >>
Login
Message << Older Topic   Newer Topic >>
 RE: Re: Create User Script - 7/26/2005 1:45:36 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
hi esnmb:

The code above does work, i know that because i have tested it, but what i mean is if i wanted option 1 to do abc and option 2 to do xyz would i not need to put somewhere if option if optio 2 then etc etc

(in reply to esnmb)
 
 
Post #: 101
 
 RE: Re: Create User Script - 7/26/2005 1:53:27 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
OHHH.  Sorry about that.

 <SCRIPT LANGUAGE="VBScript">
  'Indicates which option in DropDown1 was selected
Sub RunScript
  Select Case DropDown1.Value
      Case 1 MsgBox "Option 1 selected"
      Case 2 MsgBox "Option 2 selected"
      Case 3 MsgBox "Option 3 selected"
      Case 4 MsgBox "Option 4 selected"
  End Select

End Sub

</SCRIPT>
<body>
<select size="1" name="DropDown1" onChange="RunScript">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
</body>
</html>

(in reply to cjwallace)
 
 
Post #: 102
 
 RE: Re: Create User Script - 7/26/2005 1:59:27 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Or....


 <SCRIPT LANGUAGE="VBScript">
  'Indicates which option in DropDown1 was selected
Sub RunScript
 msgbox DropDown1.Value
End Sub

</SCRIPT>
<body>
<select size="1" name="DropDown1" onChange="RunScript">
<option value="ABC">Option 1</option>
<option value="XYZ">Option 2</option>
<option value="123">Option 3</option>
<option value="Blah Blah">Option 4</option>
</select>
</body>
</html>

(in reply to esnmb)
 
 
Post #: 103
 
 RE: Re: Create User Script - 7/26/2005 2:52:06 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi esnmb: I think i have found what i was looking for. I think what i have below will work


For Each objOption in OptionChooser.Options
           If objOption.Selected Then
               Msgbox objOption.InnerText
               Msgbox objOption.ID
               Msgbox objOption.Value

               If objOption.Value = "1" Then
                   MsgBox "The value was 1"
               ElseIf objOption.Value = "2" Then
                   MsgBox "The value was 2"
               ElseIf objOption.Value = "3" Then
                   MsgBox "The value was 3"
               End If

           End If
       Next

(in reply to esnmb)
 
 
Post #: 104
 
 RE: Re: Create User Script - 7/27/2005 1:54:51 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
With my script can anyone tell me or show me how i might make my script open in the middle of the screen?

I am using a HTA

Many thanks

(in reply to cjwallace)
 
 
Post #: 105
 
 RE: Re: Create User Script - 7/27/2005 2:11:33 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Not sure how to determine the center of the screen since resolutions will be different, but you can place this in your window_OnLoad sub or in a sub that runs as soon as the HTA launches:

window.moveTo x, y ' replace x and y with coordinates.  You're going to have to play with this one a bit.

(in reply to cjwallace)
 
 
Post #: 106
 
 RE: Re: Create User Script - 7/27/2005 2:15:03 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
ennmb:

Hello mate, thanks for the reply.

In my login script i use this:

Set IE = CreateObject("InternetExplorer.Application")
With IE
   .navigate "\\withers.net\SysVol\withers.net\scripts\GN\logon.htm"
   .resizable=0
   .height=500
   .width=350
   .menubar=0
   .toolbar=0
   .statusBar=0
   .visible=1
   .Top = (IE.Document.ParentWindow.Screen.AvailHeight - IE.Height) / 2
   .Left = (IE.Document.ParentWindow.Screen.AvailWidth - IE.Width) / 2
End With

But i dont think i can use this with HTA as the above script is creating IE

Any ideas?

Thanks for your help

(in reply to esnmb)
 
 
Post #: 107
 
 RE: Re: Create User Script - 7/27/2005 2:20:55 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Is your logon script an HTA?

I used it with my HTA with out a problem.  window.Whatever refers to the browser window.  I also use window.resizeTo x, y in my HTA.

(in reply to cjwallace)
 
 
Post #: 108
 
 RE: Re: Create User Script - 7/27/2005 2:49:08 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hello mate, no my login script is just pure vbscript which creates an instance of IE

What part of the script did you use?

(in reply to esnmb)
 
 
Post #: 109
 
 RE: Re: Create User Script - 7/27/2005 3:00:05 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Oh.  I thought you were trying to position your HTA.

Could you just do:

Set IE = CreateObject("InternetExplorer.Application")
With IE
   .navigate "\\withers.net\SysVol\withers.net\scripts\GN\logon.htm"
   .resizable=0
   .height=500
   .width=350
   .menubar=0
   .toolbar=0
   .statusBar=0
   .visible=1
   .Top = (IE.Document.ParentWindow.Screen.AvailHeight - IE.Height) / 2
   .Left = (IE.Document.ParentWindow.Screen.AvailWidth - IE.Width) / 2
    .moveTo x, y
End With

(in reply to cjwallace)
 
 
Post #: 110
 
 RE: Re: Create User Script - 7/28/2005 3:14:54 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hello mate, i must be missing something here but i just cant get it to work.

Where abouts in my script are you putting it?

Sorry if i am being an arse.

Thanks for your help on this

(in reply to esnmb)
 
 
Post #: 111
 
 RE: Re: Create User Script - 7/28/2005 4:05:59 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
CJWallace,

You can put the Window.MoveTo(x,y) in the logon.htm, but you must comment out the following in your VBS

  .Top = (IE.Document.ParentWindow.Screen.AvailHeight - IE.Height) / 2
  .Left = (IE.Document.ParentWindow.Screen.AvailWidth - IE.Width) / 2

or else it will be overruled....



you can add the following to logon.htm

<script language="JavaScript">
<!--
Window.MoveTo(500,600)
//-->
</script>

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to cjwallace)
 
 
Post #: 112
 
 RE: Re: Create User Script - 7/29/2005 7:38:49 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hello guys. Sorry i am being an arse and cant seem to get the hta to open in the middle of the screen.

Whare are you putting it to make it open in the middle of the screen?

Sorry i am just being an arse

The script so far

==============================================

<html>
<HTA:APPLICATION
APPLICATIONNAME="Withers LLP AD Account Creation"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
<head>
<title>Withers LLP 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">

 'This section is the error reporting for the application

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
strCN = strFirst & "\, " & strLast
Const ADS_UF_ACCOUNTDISABLE = 2
Const ADS_PROPERTY_UPDATE = 2

' This section will create the user & set part of the General Page.

Set objOU = GetObject("LDAP://OU=CORPORATE,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
Set objUser = objOU.Create("User", "cn=" & strCN)
objUser.Put "sAMAccountName", LCase(strUser)
objUser.Put "userPrincipalName", strUser & "@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

' This section will assign the user a standard password

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

' Address Page Information

Set objUser = GetObject _
("LDAP://cn=" & strCN & ",OU=CORPORATE,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")

objUser.Put "streetAddress", "16 Old Bailey"
objUser.Put "l", "London"
objUser.Put "postalCode", "EC4M 7EG"
objUser.Put "c", "GB"
objUser.SetInfo

' General Page Information

objUser.Put "physicalDeliveryOfficeName", "London"
objUser.Put "telephoneNumber", "+44 (0)20 7597"
objUser.Put "mail", strFirst & "." & strLast & "@withersworldwide.com"
objUser.Put "wWWHomePage", "http://www.withersworldwide.com"
objUser.SetInfo

' Users Telephone Information

objUser.Put "facsimileTelephoneNumber", "+44 (0)20 7597 6543"
objUser.SetInfo

' Organization Information

objUser.Put "department", "Corporate"
objUser.Put "company", "Withers LLP"
objUser.SetInfo

'This Section Will Add the user to the Withers standard Security Groups

Const ADS_PROPERTY_APPEND = 3

Set objGroup = GetObject _
("LDAP://cn=LN London Users,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.PutEx ADS_PROPERTY_APPEND, _
"member", Array("cn=" & strCN & ",OU=CORPORATE,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.SetInfo

Set objGroup = GetObject _
("LDAP://cn=LN Corporate,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.PutEx ADS_PROPERTY_APPEND, _
"member", Array("cn=" & strCN & ",OU=CORPORATE,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.SetInfo

Set objGroup = GetObject _
("LDAP://cn=LN GWArchive,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.PutEx ADS_PROPERTY_APPEND, _
"member", Array("cn=" & strCN & ",OU=CORPORATE,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.SetInfo

' Creates where the users Roaming Profile will be stored based on Checkbox selection.

If CreateProfile.Checked = TRUE Then
       'Action 1  
       
       ' Users Profile Information

        objUser.Put "profilePath", "\\Withers.net\dfsroot\GlobalProfiles\" & strUser & ""

ElseIf CreateProfile.Checked = FALSE Then
       'Action 2
      
       ' Users Profile Information

        objUser.Put "profilePath", "\\LNFS01\Profiles$\" & strUser & ""

End If

' Users Home Drive Information

objUser.Put "homeDirectory", "\\LNFS01\Home$\" & strUser & ""
objUser.Put "homeDrive", "H"
objUser.SetInfo

'This Section will Create The Users Home Drive on \\lnfs01\home$

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder("\\LNFS01\home$\" & strUser)

'This Section will give the user change NTFS permissions to their home drives.

Set objShell = CreateObject("Wscript.Shell")
strDest = "\\LNFS01\home$\" & strUser
objShell.Run ("SetACL.exe -on """ & strDest & """ -ot file -actn ace " & "-ace ""n:WITHERS.net\" & strUser & ";p:change""")

'This Section will create the Groupwise Archive Folder on \\LNFS01\GWArchive$\%username%

Set objFolder = objFSO.CreateFolder("\\LNFS01\GWArchive\" & strUser)


' Will Disbale User Account based on Checkbox selection.

If DisableAccount.Checked Then
        ' Disables The User Account
        
Set objUser = GetObject _
("LDAP://cn=" & strCN & ",OU=CORPORATE,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
intUAC = objUser.Get("userAccountControl")
 
objUser.Put "userAccountControl", intUAC OR ADS_UF_ACCOUNTDISABLE
objUser.SetInfo
 
End If

End Sub

Sub Reload
location.Reload(True)
End Sub

Sub bodyLoaded()

window.ResizeTo 530,590 ' WIDTH, HEIGHT

End Sub

</script>
</head>
<body onLoad="bodyLoaded()">
<p class="style2" align="center"> <img border="0" src="withers.bmp" width="286" height="92"></p>
<p class="style2" align="left"> CORPORATE DEPARTMENT</p>
<p class="style2" align="left"> <font color="#CC6600">Creation
Page&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
User Options</font></p>
<table width="286" border="0" align="left" height="59">
<tr>
<td width="94" height="10"><span class="style5"><b>*</b></span>Login ID: </td>
<td width="187" height="10"><input type="text" name="textbox0" size="23"></td>
</tr>
<tr>
<td width="94" height="14"><span class="style5"><b>*</b></span>First Name:</td>
<td width="187" height="14"><input type="text" name="textbox1" size="23"></td>
</tr>
<tr>
<td width="94" height="13">Middle Initial: </td>
<td width="187" height="13"><input type="text" name="textbox2" size="23"></td>
</tr>
<tr>
<td width="94" height="1"><span class="style5"><b>*</b></span>Last Name: </td>
<td width="187" height="1"><input type="text" name="textbox3" size="23"></td>
</table>

<table width="228" border="0" align="left" height="28">
<tr>
<td width="191" height="1">Corporate Fee Earner?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
<td width="28" height="1"><input type="checkbox" name="CreateProfile" value="CreateProfile"></td>
</tr>
<tr>
<td width="191" height="1">Disable User Account? </td>
<td width="28" height="1"><input type="checkbox" name="DisableAccount" value="DisableAccount"></td>
</tr>
</table>

<br>
<br>
<br>
<br>
<p>
<br>
<br>
<br>
</p>
<p>
<input type="button" name="Submit" value="Submit" onClick="CreateAccount">
</p>
<p>The new employee will also be required <br>
to change their password at first logon. </p>
<p class="style3"><b><span class="style6">*</span>  </b> Indicates Required Field</p>
<p>
<input id="reloadbutton" class="button" type="reset" value="Clear Form" name="reload_button" onClick="Reload">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#CC6600" size="2">Script designed by Craig Wallace,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;London Systems Analyst&nbsp;30.05.05 v2</font>
</p>
<p>
<input type="button" value=" Exit " name="close_button" onClick="Self.Close">
</p>
</body>
</html>

(in reply to Snipah)
 
 
Post #: 113
 
 RE: Re: Create User Script - 7/29/2005 8:05:06 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Hey there.....

use this:

Sub bodyLoaded()
theleft = (screen.availWidth - document.body.clientWidth) / 2
thetop = (screen.availHeight - document.body.clientHeight) / 2
window.moveTo theleft,thetop
End Sub

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to cjwallace)
 
 
Post #: 114
 
 RE: Re: Create User Script - 8/7/2005 11:38:49 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Snipah:

Thanks mate that worked.

Thanks for your help

(in reply to Snipah)
 
 
Post #: 115
 
 RE: Re: Create User Script - 8/7/2005 11:40:36 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
What I would like to do is have another box on the main page for extension number and once a value is entered is will add it to

objUser.Put "telephoneNumber", "  "
 
Can anyone help me with this, Many thanks in advance

Below is the code so far.

==============================

<html>
<HTA:APPLICATION
APPLICATIONNAME=
"Withers LLP AD Account Creation"

SCROLL=
"no"

SINGLEINSTANCE=
"no"

WINDOWSTATE=
"normal"

>
<head>
<title>
Withers LLP User Account Creation Form</title>
<style type=
"text/css">

<!--
.style3 {font-size: 13px}
body, td {
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">

'This section is the error reporting for the application

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
strCN = strFirst & "\, " & strLast
Const ADS_UF_ACCOUNTDISABLE = 2
Const ADS_PROPERTY_UPDATE = 2
' This section will create the user & set part of the General Page.
Set objOU = GetObject("LDAP://OU=CORPORATE,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
Set objUser = objOU.Create("User", "cn=" & strCN)
objUser.Put "sAMAccountName", LCase(strUser)
objUser.Put "userPrincipalName", strUser & "@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
' This section will assign the user a standard password
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
' Address Page Information
Set objUser = GetObject _
("LDAP://cn=" & strCN & ",OU=CORPORATE,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objUser.Put "streetAddress", "16 Old Bailey"
objUser.Put "l", "London"
objUser.Put "postalCode", "EC4M 7EG"
objUser.Put "c", "GB"
objUser.SetInfo
' General Page Information
objUser.Put "physicalDeliveryOfficeName", "London"
objUser.Put "telephoneNumber", "0000"
objUser.Put "mail", strFirst & "." & strLast & "@withersworldwide.com"
objUser.Put "wWWHomePage", "http://www.withersworldwide.com"
objUser.SetInfo
' Users Telephone Information
objUser.Put "facsimileTelephoneNumber", "+44 (0)20 7597 6543"
objUser.SetInfo
' Organization Information
objUser.Put "department", "Corporate"
objUser.Put "company", "Withers LLP"
objUser.SetInfo
'This Section Will Add the user to the Withers standard Security Groups
Const ADS_PROPERTY_APPEND = 3
Set objGroup = GetObject _
("LDAP://cn=LN London Users,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.PutEx ADS_PROPERTY_APPEND, _
"member", Array("cn=" & strCN & ",OU=CORPORATE,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.SetInfo
Set objGroup = GetObject _
("LDAP://cn=LN Corporate,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.PutEx ADS_PROPERTY_APPEND, _
"member", Array("cn=" & strCN & ",OU=CORPORATE,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.SetInfo
' Creates where the users Roaming Profile will be stored based on Checkbox selection.
If CreateProfile.Checked = TRUE Then
' Use DFS Share
' Users Profile Information
objUser.Put "profilePath", "\\Withers.net\dfsroot\GlobalProfiles\" & strUser & ""
ElseIf CreateProfile.Checked = FALSE Then
' Use File Server
' Users Profile Information
objUser.Put "profilePath", "\\LNFS01\Profiles$\" & strUser & ""
End If
' Users Home Drive Information
objUser.Put "homeDirectory", "\\LNFS01\Home$\" & strUser & ""
objUser.Put "homeDrive", "H"
objUser.SetInfo
'This Section will Create The Users Home Drive on \\lnfs01\home$
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder("\\LNFS01\home$\" & strUser)
'This Section will give the user change NTFS permissions to their home drives.
Set objShell = CreateObject("Wscript.Shell")
strDest = "\\LNFS01\home$\" & strUser
objShell.Run ("SetACL.exe -on """ & strDest & """ -ot file -actn ace " & "-ace ""n:WITHERS.net\" & strUser & ";p:change""")
'This Section will create the Groupwise Archive Folder on \\LNFS01\GWArchive$\%username% & Add them to the GroupWise Security Group
if GroupwiseUser.checked Then
' Creates GroupWise Achive Folder
Set objFolder = objFSO.CreateFolder("\\LNFS01\GWArchive$\" & strUser)
Set objGroup = GetObject _
("LDAP://cn=LN GWArchive,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.PutEx ADS_PROPERTY_APPEND, _
"member", Array("cn=" & strCN & ",OU=CORPORATE,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.SetInfo
End if
' Will Disbale User Account based on Checkbox selection.
If DisableAccount.Checked Then
' Disables The User Account
Set objUser = GetObject _
("LDAP://cn=" & strCN & ",OU=CORPORATE,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
intUAC = objUser.Get("userAccountControl")
objUser.Put "userAccountControl", intUAC OR ADS_UF_ACCOUNTDISABLE
objUser.SetInfo
End If
End Sub
Sub Reload
location.Reload(True)
End Sub
Sub bodyLoaded()
theleft = (screen.availWidth - document.body.clientWidth) / 2
thetop = (screen.availHeight - document.body.clientHeight) / 2
window.moveTo theleft,thetop
window.ResizeTo 550,560 ' WIDTH, HEIGHT
End Sub

</script>
</head>
<body onLoad=
"bodyLoaded()" style="background-attachment: fixed">
<p class=
"style2" align="center"> <img border="0" src="withers.bmp" width="286" height="92"></p>
<p class=
"style2" align="left"> LONDON CORPORATE DEPARTMENT</p>
<p class=
"style2" align="left"> <font color="#CC6600">Create User&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;User Options</font></p>
<table width=
"280" border="2" align="left" height="59">
<tr>
<td width=
"93" height="10"><span class="style5"><b>*</b></span>Login ID: </td>
<td width=
"169" height="10"><input type="text" name="textbox0" size="23"></td>
</tr>
<tr>
<td width=
"93" height="14"><span class="style5"><b>*</b></span>First Name:</td>
<td width=
"169" height="14"><input type="text" name="textbox1" size="23"></td>
</tr>
<tr>
<td width=
"93" height="13">Middle Initial: </td>
<td width=
"169" height="13"><input type="text" name="textbox2" size="23"></td>
</tr>
<tr>
<td width=
"93" height="1"><span class="style5"><b>*</b></span>Last Name: </td>
<td width=
"169" height="1"><input type="text" name="textbox3" size="23"></td>
</table>

<table width=
"239" border="2" align="left" height="80">
<tr>
<td width=
"194" height="24">Corporate Fee Earner?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
<td width=
"27" height="24"><input type="checkbox" name="CreateProfile" value="CreateProfile"></td>
</tr>
<tr>
<td width=
"194" height="25">GroupWise User?</td>
<td width=
"27" height="25">
<input type=
"checkbox" name="GroupwiseUser" value="GroupwiseUser"></td>
</tr>
<tr>
<td width=
"194" height="25">Disable User Account? </td>
<td width=
"27" height="25"><input type="checkbox" name="DisableAccount" value="DisableAccount"></td>
</tr>
</table>
<p><br>
<br>
<br>
<br>
<br>
<br>

&nbsp;
</p>
<p>
<input type=
"button" name="Submit" value="Submit" onClick="CreateAccount">
</p>
<p class=
"style3"><b><span class="style6">*</span> </b> Indicates Required Field</p>
<p>
<input id=
"reloadbutton" class="button" type="reset" value="Clear Form" name="reload_button" onClick="Reload">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#CC6600" size="2">Script designed by Craig Wallace,<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;London Systems Analyst&nbsp;30.05.05 v3
</font>
</p>
<p>
<input type=
"button" value=" Exit " name="close_button" onClick="Self.Close">
</p>
</body>
</html>

(in reply to cjwallace)
 
 
Post #: 116
 
 RE: Re: Create User Script - 8/8/2005 9:21:50 AM   
  ThePariah

 

Posts: 15
Score: 0
Joined: 6/14/2005
From: United Kingdom
Status: offline

<html>
<head>
<title>User Account Creation Form v2.0</title>
<HTA:APPLICATION
ID = "AccountCreationApp"
APPLICATIONNAME="Account Creation"
BORDER = "thin"
CAPTION = "yes"
RESIZE = "no"
ICON = "sprocket.ico"
SHOWINTASKBAR = "yes"
SINGLEINSTANCE = "yes"
SYSMENU = "yes"
WINDOWSTATE = "normal"
SCROLL = "yes"
SCROLLFLAT = "yes"
VERSION = "2.0"
INNERBORDER = "no"
SELECTION = "no"
MAXIMIZEBUTTON = "no"
MINIMIZEBUTTON = "yes"
NAVIGABLE = "yes"
CONTEXTMENU = "yes"
BORDERSTYLE = "normal">
</hta>
<style>
BODY
{
background-color: #E5ECF9;
font-family: Helvetica;
font-size: 8pt;
margin-top: 10px;
margin-left: 20px;
margin-right: 10px;
margin-bottom: 10px;
scrollbar-track-color: #E5ECF9;
scrollbar-3dlight-color: #E5ECF9;
scrollbar-arrow-color: #E5ECF9;
scrollbar-base-color: #E5ECF9;
scrollbar-darkshadow-color: #E5ECF9;
scrollbar-face-color: #E5ECF9;
scrollbar-highlight-color: #E5ECF9;
scrollbar-shadow-color: #E5ECF9
}
TD
{
font-family: Trebuchet MS;
font-size: 8pt;
}
LEGEND
{
font-family: Trebuchet MS;
font-size: 10pt;
}
SELECT
{
font-family: Trebuchet MS;
font-size: 8pt;
width:195px
}
INPUT
{
font-family: Trebuchet MS;
font-size: 8pt;
}
</style>


<script language="VBScript">
Dim defaultNC, BaseOU
defaultNC = GetObject("LDAP://RootDSE").Get("DefaultNamingContext")
BaseOU = "OU=Domain Clients," & defaultNC
Logpath ="C:\logs\"
Const FORAPPENDING = 8
sub window_onload
Dim x,y
x = (window.screen.width - 750) / 2
y = (window.screen.height - 700) / 2
If x < 0 Then x = 0
If y < 0 Then y = 0
window.resizeTo 765,600
window.moveTo x,y
end sub
Sub chkExch_OnClick()
If chkExch.checked = true Then
cbxExch.Disabled = 0
Else
cbxExch.Disabled = 1
End If
End Sub
Sub chkDL_OnClick()
If chkDL.checked = true Then
cbxDL.Disabled = 1
Else
cbxDL.Disabled = 0
End If
End Sub
' ## Start user account creation process ##
Sub CreateAccount
strUser = txtUser.Value
If strUser = "" Then
MsgBox "You are missing required fields.",64, "Alert"
Exit Sub
End If
strFirst = txtFirst.Value
If strFirst = "" Then
MsgBox "You are missing required fields.",64, "Alert"
Exit Sub
End If
strInitial = txtMiddle.Value
strLast = txtLast.Value
If strLast = "" Then
MsgBox "You are missing required fields.",64, "Alert"
Exit Sub
End If
strDisplay = UCase(Left(strLast, 1)) & LCase(Right(strLast, Len(strLast) - 1)) & " " _
& UCase(Left(strFirst, 1)) & LCase(Right(strFirst, Len(strFirst) - 1))
strTitle = txtTitle.Value
strOffice = cbxSite.Value
strDepartment = txtDepartment.Value
strCompany = txtCompany.Value
strManager = txtManager.Value
strCN = UCase(Left(strLast, 1)) & LCase(Right(strLast, Len(strLast) - 1)) & " " _
& UCase(Left(strFirst, 1)) & LCase(Right(strFirst, Len(strFirst) - 1))
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<GC://" & defaultNC & ">;(&(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

Const FORWRITING= 2
Const ADS_UF_ACCOUNTDISABLE = 2
Const ADS_PROPERTY_UPDATE = 2
Const ADS_PROPERTY_APPEND = 3

' ## Determine if Creation of User Mailbox required ##
If chkExch.checked = "True" And cbxExch.value = "cbxExchAlert" Then
MsgBox "You must select either a Server/Mailstore or " & vbcrlf _
& "de-select the 'Create Mailbox' checkbox." ,64, "Alert"
Exit Sub
End If
' ## Add user to required Distribution List ##
If chkDL.checked ="True" And cbxDL.value = "cbxDLAlert" Then
MsgBox "You must select a Distribution List or " & vbcrlf _
& "de-select the 'Distribution List' checkbox." ,64, "Alert"
Exit Sub
End If
' ## Ensure users site/office selected ##
If cbxSite.Value = "cbxOfficeAlert" Then
MsgBox "You must select the users office.",64, "Alert"
Exit Sub
End If
Select Case cbxSite.Value
Case "Birmingham"
strOffice = "Birmingham"
strLDAPdn = "OU=_ Birmingham," & BaseOU
strUserServer = "Northsea"
Case "Exeter"
strOffice = "Exeter"
strLDAPdn = "OU=_ Exeter," & BaseOU
strUserServer = "Cluster"
Case "Hatfield"
strOffice = "Hatfield"
strLDAPdn = "OU=_ Hatfield," & BaseOU
strUserServer = "Data1Hat"
Case "Leeds"
strOffice = "Leeds"
strLDAPdn = "OU=_ Leeds," & BaseOU
strUserServer = "Sagat"
Case "Newcastle"
strOffice = "Newcastle"
strLDAPdn = "OU=_ Newcastle," & BaseOU
strUserServer = "fluorine" <!-- Arsenic -->
Case "Other"
strOffice = "Other"
strLDAPdn = "OU=_ Other," & BaseOU
strUserServer = "fluorine"
Case "Other"
strOffice = "Other"
strLDAPdn = "OU=_ Oxford," & BaseOU
strUserServer = "Data1Oxf"
Case "Paddington"
strOffice = "Paddington"
strLDAPdn = "OU=_ Paddington," & BaseOU
strUserServer = "Data1Pad"
Case "Portland House"
strOffice = "Portland"
strLDAPdn = "OU=_ Portland House," & BaseOU
strUserServer = "Data1Pot"
Case "Redditch"
strOffice = "Redditch"
strLDAPdn = "OU=_ Redditch," & BaseOU
strUserServer = "Red-DC"
Case "Richmond House"
strOffice = "Richmond House"
strLDAPdn = "OU=_ Richmond House," & BaseOU
strUserServer = "Data1Rich"
Case "Slough"
strOffice = "Slough"
strLDAPdn = "OU=_ Slough," & BaseOU
strUserServer = "Data1Slo"
Case "Tavistock"
strOffice = "Tavistock House"
strLDAPdn = "OU=_ Tavistock House," & BaseOU
strUserServer = "fluorine" <!-- maverick -->
Case "Winchester"
strOffice = "Winchester"
strLDAPdn = "OU=_ Winchester," & BaseOU
strUserServer = "fluorine"
End Select

Set objOU = GetObject("LDAP://" & strLDAPdn)
Set objUser = objOU.Create("User", "cn=" & strCN)

objUser.Put "sAMAccountName", LCase(strUser)
objUser.SetInfo
objUser.Put "givenName", UCase(Left(strFirst, 1)) & LCase(Right(strFirst, Len(strFirst) - 1))
If strInitial <> "" Then
objUser.Put "initials", UCase(Left(strInitial, 1)) & LCase(Right(strInitial, Len(strInitial) - 1))
End If
objUser.Put "sn", UCase(Left(strLast, 1)) & LCase(Right(strLast, Len(strLast) - 1))
objUser.Put "displayName", UCase(Left(strLast, 1)) & LCase(Right(strLast, Len(strLast) - 1)) & " " _
& UCase(Left(strFirst, 1)) & LCase(Right(strFirst, Len(strFirst) - 1))

If strTitle <> "" Then
objUser.put "title", strTitle
End If
If strDepartment <> "" Then
objUser.put "department", strDepartment
End If
If strCompany <> "" Then
objUser.put "company", strCompany
End If
If strManager <> "" Then
objUser.put "manager", strManager
End If
objUser.put "physicalDeliveryOfficeName", strOffice
objUser.put "description", strTitle
objUser.Put "userPrincipalName", LCase(strUser) & "@" & defaultNC

objUser.SetPassword "welcome&q