Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


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: Create User Script
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  3 4 [5] 6 7   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Re: Create User Script - 7/1/2005 8:16:28 AM   
  cjwallace

 

Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Same I am a Network Administrator as well, and I love vbscript. I am no programmer and don̉t claim to be one, I am learning this stuff from guys off this site who know what they are doing.

VBScript is just so powerful and that̉s why I like it so much and I get a real kick out of when it works, hence why I like IT and Networks so much.

Esnmb: I like the sound of the stuff you have expanded on, and some of it is what I plan to do with mine. I am basically trying to make life better and easier for the Network guys I work with and myself.

The next thing I want to expand on is if the user you are creating is a standard network user or a user who is going to roam between offices. The only real differences at this time are where their roaming profiles need to be created. Standard user = network share, Roaming Users = DFS Share.

What I would like to happen is when you click on submit that the script asks you what you want to do OR have a check box on the main page for Standard or Roaming

I also like the email notification and this would be hugely beneficial

(in reply to cjwallace)
 
 
Post #: 81
 
 RE: Re: Create User Script - 7/11/2005 4:16:36 AM   
  cjwallace

 

Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi Guys, I thought I would open this post up again.

How with the code I am using previously, can I add either a check box or a window that will prompt the user? I would like the user who is creating the user be asked:

Is this user a standard user?

Or

is this user a global roaming user?

Depending on which one the user selects will depend on where there roaming profile is created

Can anyone help with this?

(in reply to cjwallace)
 
 
Post #: 82
 
 RE: Re: Create User Script - 7/11/2005 5:07:12 AM   
  esnmb

 

Posts: 431
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Here is the HTML for the checkbox:

<input type="checkbox" name="CreateMail" value="CreateMail" checked="Checked">Create Mailbox<br> ' Notice the checked="Checked".  This sets the default value to checked.

Then in my script section I would have this:

If CreateMail.Checked Then
       ' Creates the users mailbox
       Set oIADSUser = GetObject("LDAP://CN=" & strCN & "," & strLDAP)
       oIADSUser.CreateMailbox "LDAP://CN=Mailbox Store (EXCHANGE),CN=First Storage Group,CN=InformationStore,CN=EXCHANGE,CN=Servers,CN=MIDDLETOWN,CN=Administrative     Groups,CN=DOMAIN,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=DOMAIN,DC=com"
       oIADSUser.SetInfo
End If

< Message edited by esnmb -- 1/2/2007 5:29:41 AM >

(in reply to cjwallace)
 
 
Post #: 83
 
 RE: Re: Create User Script - 7/11/2005 8:21:27 PM   
  cjwallace

 

Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
esnmb: Hello mate, as ever thanks for the reply. I have had a look at what you said.

Your script seems to create a mailbox if it is checked or if its not it will just ignore it, What i am trying to do is, if its check do Action 1 and if it is not checked do Action 2

Any ideas on how i could achive this. I have been playing around but just ended up making a mess of my script.

(in reply to esnmb)
 
 
Post #: 84
 
 RE: Re: Create User Script - 7/11/2005 9:02:51 PM   
  sdeklerk

 

Posts: 16
Score: 0
Joined: 6/28/2005
From: the Netherlands
Status: offline
couldn't you use something like this then:

If CreateMail.Checked = TRUE Then
    'Action 1 
     Set oIADSUser = GetObject("LDAP://CN=" & strCN & "," & strLDAP)
    oIADSUser.CreateMailbox "LDAP://CN=Mailbox Store (EXCHANGE),CN=First Storage Group,CN=InformationStore,CN=EXCHANGE,CN=Servers,CN=MIDDLETOWN,CN=Administrative     Groups,CN=DOMAIN,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=DOMAIN,DC=com"
    oIADSUser.SetInfo
ElseIf CreateMail.Checked = FALSE Then
     'Action 2
     'state your code here
End If

< Message edited by esnmb -- 1/2/2007 5:35:59 AM >

(in reply to cjwallace)
 
 
Post #: 85
 
 RE: Re: Create User Script - 7/12/2005 12:51:14 AM   
  esnmb

 

Posts: 431
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Exactly.

(in reply to sdeklerk)
 
 
Post #: 86
 
 RE: Re: Create User Script - 7/12/2005 1:11:34 AM   
  cjwallace

 

Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Thanks guys, that worked a treat.

Sorry not sure if i have said before i am still very new to vbscript so i am still learning stuff.

But again Thanks for the reply.

(in reply to esnmb)
 
 
Post #: 87
 
 RE: Re: Create User Script - 7/12/2005 2:36:04 AM   
  cjwallace

 

Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi Guys. Thanks for the help so far.

I am not sure how to do this. Basically this script below will create a user who is in the family department within my firm. What i would like to do is have on the main page 6 checkbox's for each of the departments and depending on which department is selected it will create the user.

Can anyone help me with this, what i have tied really messed my script up. I am just trying to have one script that will each department rather than 6 scripts to maintain

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=FAMILY,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=FAMILY,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", "Family Department"
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=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.SetInfo
Set objGroup = GetObject _
("LDAP://cn=LN Family,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.PutEx ADS_PROPERTY_APPEND, _
"member", Array("cn=" & strCN & ",OU=FAMILY,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=FAMILY,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", "\\LNFS01\LNGlobalProfiles$\" & 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
       
rem Const ADS_UF_ACCOUNTDISABLE = 2

Set objUser = GetObject _
("LDAP://cn=" & strCN & ",OU=FAMILY,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 400,685 ' WIDTH, HEIGHT
End Sub
</script>
</head>
<body onLoad="bodyLoaded()">
<p><img src="withers.bmp" width="286" height="92"></p>
<p class="style2" align="left"> <font color="#CC6600">&nbsp;Account Creation
Page</font></p>
<table width="369" border="0" align="left" height="208">
<tr>
<td width="187" height="25"><span class="style5"><b>*</b></span>Login ID: </td>
<td width="173" height="25"><input type="text" name="textbox0" size="23"></td>
</tr>
<tr>
<td width="187" height="25"><span class="style5"><b>*</b></span>First Name:</td>
<td width="173" height="25"><input type="text" name="textbox1" size="23"></td>
</tr>
<tr>
<td width="187" height="25">Middle Initial: </td>
<td width="173" height="25"><input type="text" name="textbox2" size="23"></td>
</tr>
<tr>
<td width="187" height="25"><span class="style5"><b>*</b></span>Last Name: </td>
<td width="173" height="25"><input type="text" name="textbox3" size="23"></td>
<tr>
<td width="187" height="20"><font color="#FF0000"><b>User Options</b></font> </td>
<td width="173" height="20"></td>
<tr>
<td width="187" height="38">International roaming&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
<td width="173" height="38"><input type="checkbox" name="CreateProfile" value="CreateProfile"></td>
</tr>
<tr>
<td width="187" height="38">Disable User Account </td>
<td width="173" height="38"><input type="checkbox" name="DisableAccount" value="DisableAccount"></td>
</tr>
</table>
<br>
<br>
<br>
<p><br>
</p>
<p>
<br>
</p>
<p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<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">
</p>
<p>
<input type="button" value=" Exit " name="close_button" onClick="Self.Close"><br>
<br>
</p>
</body>
</html>




(in reply to cjwallace)
 
 
Post #: 88
 
 RE: Re: Create User Script - 7/12/2005 7:38:42 AM   
  ExHorn04

 

Posts: 4
Score: 0
Joined: 6/8/2005
From: USA
Status: offline
quote:

ORIGINAL: esnmb

Here is the HTML for the checkbox:

<input type="checkbox" name="CreateMail" value="CreateMail" checked="Checked">Create Mailbox<br> ' Notice the checked="Checked".  This sets the default value to checked.

Then in my script section I would have this:

If CreateMail.Checked Then
      ' Creates the users mailbox
      Set oIADSUser = GetObject("LDAP://CN=" & strCN & "," & strLDAP)
      oIADSUser.CreateMailbox "LDAP://CN=Mailbox Store (EXCHANGE),CN=First Storage Group,CN=InformationStore,CN=EXCHANGE,CN=Servers,CN=MIDDLETOWN,CN=Administrative     Groups,CN=DOMAIN,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=DOMAIN,DC=com"
      oIADSUser.SetInfo
End If


When attempting to do this I am getting an error that states that createmail does not have a value when referencing:

If CreateMail.Checked Then

Do I need to add anything else to the code to allow it to recognize that it is checked?  I basically mirrored what is above, but I changed mailbox location, but it does not get that far to error our there if there in fact is an error. Thanks.

Chris

< Message edited by esnmb -- 1/2/2007 5:36:20 AM >

(in reply to esnmb)
 
 
Post #: 89
 
 RE: Re: Create User Script - 7/12/2005 7:40:23 AM   
  ExHorn04

 

Posts: 4
Score: 0
Joined: 6/8/2005
From: USA
Status: offline
quote:

ORIGINAL: cjwallace

Hi Guys. Thanks for the help so far.

I am not sure how to do this. Basically this script below will create a user who is in the family department within my firm. What i would like to do is have on the main page 6 checkbox's for each of the departments and depending on which department is selected it will create the user.

Can anyone help me with this, what i have tied really messed my script up. I am just trying to have one script that will each department rather than 6 scripts to maintain

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=FAMILY,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=FAMILY,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", "Family Department"
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=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.SetInfo
Set objGroup = GetObject _
("LDAP://cn=LN Family,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.PutEx ADS_PROPERTY_APPEND, _
"member", Array("cn=" & strCN & ",OU=FAMILY,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=FAMILY,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", "\\LNFS01\LNGlobalProfiles$\" & 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
      
rem Const ADS_UF_ACCOUNTDISABLE = 2

Set objUser = GetObject _
("LDAP://cn=" & strCN & ",OU=FAMILY,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 400,685 ' WIDTH, HEIGHT
End Sub
</script>
</head>
<body onLoad="bodyLoaded()">
<p><img src="withers.bmp" width="286" height="92"></p>
<p class="style2" align="left"> <font color="#CC6600">&nbsp;Account Creation
Page</font></p>
<table width="369" border="0" align="left" height="208">
<tr>
<td width="187" height="25"><span class="style5"><b>*</b></span>Login ID: </td>
<td width="173" height="25"><input type="text" name="textbox0" size="23"></td>
</tr>
<tr>
<td width="187" height="25"><span class="style5"><b>*</b></span>First Name:</td>
<td width="173" height="25"><input type="text" name="textbox1" size="23"></td>
</tr>
<tr>
<td width="187" height="25">Middle Initial: </td>
<td width="173" height="25"><input type="text" name="textbox2" size="23"></td>
</tr>
<tr>
<td width="187" height="25"><span class="style5"><b>*</b></span>Last Name: </td>
<td width="173" height="25"><input type="text" name="textbox3" size="23"></td>
<tr>
<td width="187" height="20"><font color="#FF0000"><b>User Options</b></font> </td>
<td width="173" height="20"></td>
<tr>
<td width="187" height="38">International roaming&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
<td width="173" height="38"><input type="checkbox" name="CreateProfile" value="CreateProfile"></td>
</tr>
<tr>
<td width="187" height="38">Disable User Account </td>
<td width="173" height="38"><input type="checkbox" name="DisableAccount" value="DisableAccount"></td>
</tr>
</table>
<br>
<br>
<br>
<p><br>
</p>
<p>
<br>
</p>
<p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<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">
</p>
<p>
<input type="button" value=" Exit " name="close_button" onClick="Self.Close"><br>
<br>
</p>
</body>
</html>






Are you not automatically creating an email address for your users?

(in reply to cjwallace)
 
 
Post #: 90
 
 RE: Re: Create User Script - 7/14/2005 6:17:59 PM   
  Cary Shultz

 

Posts: 4
Score: 0
Joined: 7/1/2005
From: USA
Status: offline
Good morning, CJ!

I have a quick question for you regarding the following section of your HTA:

     ' 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)


When I use the bolded, red code I get an error message.  That error message is:

Line: 142
Char: 1
Error: object reguired:  'objShell'
Code: 0
URL: path to .hta file

I do have the latest version of SetACL.exe located at c:\winnt\setacl.exe  ( but I am sure that this has nothing to do with this problem ).

Do you have any suggestions?

Also, you wanted to add some checkboxes ( for group membership ).  Have you been succesful in implementing this?  What I am trying to do is to create the situation where all of the OUs show up in a drop-down list so that the location of the user account object is not hard-coded....I believe that the solutions is forms but I have not had the time to try that just yet.  esnmb replied to a post that I created about one week ago.

I am also trying to do the same for the 'home server' for the mailbox ( as well as infromation store, storage group and server.... ).

Hope that all is well,

Cary

(in reply to cjwallace)
 
 
Post #: 91
 
 RE: Re: Create User Script - 7/18/2005 6:08:19 AM   
  esnmb

 

Posts: 431
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
quote:

Set objShell = CreateObject("Wscript.Shell")

Did you add this line?

(in reply to Cary Shultz)
 
 
Post #: 92
 
 RE: Re: Create User Script - 7/18/2005 10:36:27 PM   
  Cary Shultz

 

Posts: 4
Score: 0
Joined: 7/1/2005
From: USA
Status: offline
Now, that would have been a good idea, huh?

No, in my haste I did not include this line.....I did catch this, however, and added it and everything works very well now.  I should have posted that I found the culprit ( me! ).

Do you have any tips on enummerating all of the OUs in the AD environment and having them populoate the drop down list for the creation of the user account object?  I will be playing with this and trying to figure it out.  Being new to something is sometimes a lot of fun, sometimes a little frustrating.  But it is the discovery process along the way that is a lot of fun!

So, if there were five OUs in the environment all five of them would show up in the drop down list.  I have not yet played with your forms suggestion.  Have not yet had the time, to be honest.  Will in the next couple days, though.

Thanks,

Cary

(in reply to esnmb)
 
 
Post #: 93
 
 RE: Re: Create User Script - 7/23/2005 11:01:07 AM   
  ThePariah

 

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

How do you populate your dropdowns? At present i am hardcoding my dropdown with the 12 OU that our users are created in. This is not ideal as we are in the process of a migration and i would like incorporate a more dynamic method of populating the dropdown.

This is quite an important aspect of the user creation process using HTA for me as i will need to add a number of dropdowns for elements such as Mail Server, Storage groups etc.

Do you have and example of how you have populated your  dropdown? If so would you mind posting an example.

Thanks

(in reply to Cary Shultz)
 
 
Post #: 94
 
 RE: Re: Create User Script - 7/25/2005 8:15:10 AM   
  cjwallace

 

Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi Guys, sorry i have not been on for a whille. Below is a copy of my script so far. As you can see from the bold section i am using check boxs to perform where the users profile is stored. i would like to use a drop down menu.

Can someone explain how i can use dropdown menu?

Many thanks

=====================================================================
<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=FAMILY,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=FAMILY,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", "Family Department"
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=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.SetInfo

Set objGroup = GetObject _
("LDAP://cn=LN Family,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
objGroup.PutEx ADS_PROPERTY_APPEND, _
"member", Array("cn=" & strCN & ",OU=FAMILY,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=FAMILY,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", "\\LNFS01\LNGlobalProfiles$\" & 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=FAMILY,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 510,545 ' WIDTH, HEIGHT

End Sub

</script>
</head>
<body onLoad="bodyLoaded()">
<p align="center"><img src="withers.bmp" width="286" height="92"></p>
<p class="style2" align="left"> <font color="#CC6600">&nbsp;Account Creation
Page&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;User Options</font></p>
<table width="272" border="0" align="left" height="59">
<tr>
<td width="94" height="10"><span class="style5"><b>*</b></span>Login ID: </td>
<td width="173" 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="173" height="14"><input type="text" name="textbox1" size="23"></td>
</tr>
<tr>
<td width="94" height="13">Middle Initial: </td>
<td width="173" 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="173" height="1"><input type="text" name="textbox3" size="23"></td>
</table>

<table width="219" border="0" align="left" height="28">
<tr>
<td width="187" height="1">London Fee Earner&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
<td width="23" height="1"><input type="checkbox" name="CreateProfile" value="CreateProfile"></td>
</tr>
<tr>
<td width="187" height="1">Disable User Account </td>
<td width="23" 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 </p>
<p>
<input type="button" value=" Exit " name="close_button" onClick="Self.Close">
</p>
</body>
</html>






 

(in reply to ThePariah)
 
 
Post #: 95
 
 RE: Re: Create User Script - 7/25/2005 9:07:21 AM   
  esnmb

 

Posts: 431
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
I don't create one dropdown for all Groups.  Instead I create seperate ones so they are logically seperated.

Here is code for one of them.


This code is executed as soon as the script is launched:

sub CostCenter()
    Set objOU = GetObject("LDAP://OU=Cost Center,OU=Security Groups,DC=MyDomain,DC=com")
    objOU.Filter = Array("Group")

    Dim strDropDown
    strDropDown = "<select size=" & Q & "1" & Q & " name=" & Q & "DropDownCC" & Q & ">" & VBCRLF
    strDropDown = strDropDown & "<option value=" & Q & Q & ">" & "[REQUIRED - Cost Center]" & "</option>" & VBCRLF
   
    For Each objGroup In objOU
        strGroup = Mid(objGroup.Name, 4)
        strDropDown = strDropDown & "<option value=" & Q & strGroup & Q & ">" & strGroup & "</option>" & VBCRLF
    Next

    CCArea.InnerHTML = strDropDown & "</select>" & VBCRLF
    Set objOU = Nothing
end sub

Then in the HTML section, I have this:

<span id="CCArea"></span>

(in reply to cjwallace)
 
 
Post #: 96
 
 RE: Re: Create User Script - 7/25/2005 11:01:08 PM   
  cjwallace

 

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

Many thanks for the reply.

What i have below i think should work for what i want. but i cant see how if option 1 is selected it will do x and if 2 is selected it will do xx


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

<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="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 esnmb)
 
 
Post #: 97