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  5 6 [7] 8 9   next >   >>
Login
Message << Older Topic   Newer Topic >>
 RE: Re: Create User Script - 8/9/2005 3:01:27 AM   
  Snipah


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

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


haha, I tend to move certain lines in the code just to make it look neater (i.e. start with Const, then Dim, then Sub then Set blabla = nothing)

So i moved the lines above (see quote) upwards... 

moved some more to make the HTML look better also.... (i am a neat freak sometimes)

I will try to post the complete code tonight...


Snipah


PS  This is how i connect to AD:

'*** set contstants
Option Explicit
Const ADS_SCOPE_SUBTREE = 2

'*** set vars
Dim oRootDSE, DNSDomain, eNumLen, eCountry
Dim objConnection, objCommand, objRecordSet
Dim DN, oUser, msg, eNumber, wshNetwork
Dim objGroup, objMemberOf, strlist, arrGroup

'*** define vars
Set WshNetwork = CreateObject("WScript.Network")
Set oRootDSE = GetObject("LDAP://RootDSE")
DNSDomain = oRootDSE.Get("DefaultNamingContext")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

'*** start Subs
[...]

_____________________________

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

http://www.visualbasicscript.com

(in reply to cjwallace)
 
 
Post #: 121
 
 RE: Re: Create User Script - 8/9/2005 7:15:04 AM   
  cjwallace

 

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

Many thanks for all your help on this issue. It would be great if you could post the whole code so i can test it out and then move on to the next issue.

I know i need to tidy my code up , was going to get my code working then tidy it up.

Again thanks for all your help and looking forward to seeing the code..

< Message edited by cjwallace -- 8/9/2005 6:39:25 PM >

(in reply to Snipah)
 
 
Post #: 122
 
 RE: Re: Create User Script - 8/9/2005 6:40:20 PM   
  cjwallace

 

Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Ahh found this post again

(in reply to cjwallace)
 
 
Post #: 123
 
 RE: Re: Create User Script - 8/10/2005 2:43:03 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
It is not 100%, but i managed to get a better overview like this...


//edit: apperantly i had to redo it after i pasted in here.....a well, better then nothing....


<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">
<!--
body, td
{
font-family: Arial, Helvetica, sans-serif;
}
.style2
{
font-family: Arial, Helvetica, sans-serif;
font-size: 13.5pt;
color: #CC6600;
font-weight: bold;
}
.style3
{
font-size: 13px;
}
.style5
{
font-size: small; color: #FF0000;
}
.style6
{
color: #FF0000;
}
-->
</style>
<script type="text/vbscript">

'*** set contstants
Option Explicit
Const ADS_UF_ACCOUNTDISABLE = 2
Const ADS_PROPERTY_UPDATE = 2
Const ADS_PROPERTY_APPEND = 3

'*** start Subs
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

' 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", "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

'check if phone ext is actually 4 digits
If Len(txtPhoneExt.value) = 4 Then
objUser.Put "telephoneNumber", txtPhoneExt.value 'default value (see HTML) is 0000
Else
MsgBox "Please enter at least 4 digits",64, "Alert"
txtPhoneExt.select 'this to put the focus back on the error field
Exit Sub
End If

' 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

'This Section Will Add the user to the Withers standard Security Groups
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 Disable User Account based on Checkbox selection.
If DisableAccount.Checked Then
' Disables The User Account
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
'*** end of script
</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>
<tr>
<td width="93" height="1">Phone Ext.: </td>
<td width="169" height="1"><input type="text" name="txtPhoneExt" size="4" MAXLENGTH="4" value="0000"><font size="-1">(max. 4 digits)</font></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;<br><br><br></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>

< Message edited by Snipah -- 8/10/2005 2:50:24 AM >


_____________________________

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

http://www.visualbasicscript.com

(in reply to cjwallace)
 
 
Post #: 124
 
 RE: Re: Create User Script - 8/10/2005 3:04:25 AM   
  cjwallace

 

Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Snipah: Many thanks for the reply and for taking a look at my script.

I have copied into a new .hta and run the script at which point I get Line: 182 Char6 6 Error: Variable is undefined: 'theleft' Any ideas? Again many thanks for your help on this.

(in reply to Snipah)
 
 
Post #: 125
 
 RE: Re: Create User Script - 8/10/2005 4:45:17 AM   
  Snipah


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

I have added an Option Explicit to it...which means to Dim all the vars prior to use....either:

1) remove Option Explicit and it may run OK, or
2) Dim all vars and make a clean HTA (and run neatly, see below to have them all covered)

'*** set vars
Dim strUser, strFirst, strInitial, strLast, strDisplay, strCN, strDest
Dim objUser, objOU, objGroup, objFSO, objFolder, objShell
Dim intUAC, theLeft, theTop

_____________________________

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

http://www.visualbasicscript.com

(in reply to cjwallace)
 
 
Post #: 126
 
 RE: Re: Create User Script - 8/10/2005 7:38:59 AM   
  cjwallace

 

Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Thanks Snipah i will give it a go when i get in the office tomorrow

(in reply to Snipah)
 
 
Post #: 127
 
 RE: Re: Create User Script - 8/10/2005 7:19:26 PM   
  cjwallace

 

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

I have changed the code as per your advice *Please see code below*

When i run the code i get

Line: 79

Char: 21

Error: There is no such object on the server

Code 0

I have made the line in question BOLD
 
The Code so far.

Again Snipah, thanks for all your hard work on this i really do appreciate it.

================================================
<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">
<!--
body, td
{
font-family: Arial, Helvetica, sans-serif;
}
.style2
{
font-family: Arial, Helvetica, sans-serif;
font-size: 13.5pt;
color: #CC6600;
font-weight: bold;
}
.style3
{
font-size: 13px;
}
.style5
{
font-size: small; color: #FF0000;
}
.style6
{
color: #FF0000;
}
-->
</style>
<script type="text/vbscript">
'*** set contstants
Option Explicit
Const ADS_UF_ACCOUNTDISABLE = 2
Const ADS_PROPERTY_UPDATE = 2
Const ADS_PROPERTY_APPEND = 3
'*** set vars
Dim strUser, strFirst, strInitial, strLast, strDisplay, strCN, strDest
Dim objUser, objOU, objGroup, objFSO, objFolder, objShell
Dim intUAC, theLeft, theTop
'*** start Subs
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
                   ' 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", "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
                   'check if phone ext is actually 4 digits
                   If Len(txtPhoneExt.value) = 4 Then
                        objUser.Put "telephoneNumber", txtPhoneExt.value 'default value (see HTML) is 0000
                   Else
                        MsgBox "Please enter at least 4 digits",64, "Alert"
                        txtPhoneExt.select 'this to put the focus back on the error field
                        Exit Sub
                        End If
                        ' 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
                        'This Section Will Add the user to the Withers standard Security Groups
                        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 Disable User Account based on Checkbox selection.
                        If DisableAccount.Checked Then
                             ' Disables The User Account
                             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
                   '*** end of script
</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>
<tr>
<td width="93" height="1">Phone Ext.: </td>
<td width="169" height="1"><input type="text" name="txtPhoneExt" size="4" MAXLENGTH="4" value="0000"><font size="-1">(max. 4 digits)</font></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;<br><br><br></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 #: 128
 
 RE: Re: Create User Script - 8/10/2005 7:34:11 PM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Try to make it one line, or use & _

_____________________________

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

http://www.visualbasicscript.com

(in reply to cjwallace)
 
 
Post #: 129
 
 RE: Re: Create User Script - 8/10/2005 7:41:38 PM   
  cjwallace

 

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

ORIGINAL: Snipah

Try to make it one line, or use & _


Hi Snipah. I am really sorry i dont follow i am still very new to vbscript.

(in reply to Snipah)
 
 
Post #: 130
 
 RE: Re: Create User Script - 8/10/2005 10:56:02 PM   
  Snipah


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

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



No problemo...that is why we are here....

in stead of

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

try (one line)

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

_____________________________

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

http://www.visualbasicscript.com

(in reply to cjwallace)
 
 
Post #: 131
 
 RE: Re: Create User Script - 8/10/2005 11:58:11 PM   
  cjwallace

 

Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hello Snipah: I have made the change that you said, but i am still getting the same error message

I am really sorry i am not sure what to do.?


Line: 81

Char: 21

Error: There is no such object on the server

Code 0


Thanks for you support on this issue so far

(in reply to Snipah)
 
 
Post #: 132
 
 RE: Re: Create User Script - 8/11/2005 12:36:08 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
This is what i use to get user information....

'*** set contstants
Option Explicit
Const ADS_SCOPE_SUBTREE = 2

'*** set vars
Window.resizeTo 800, 600
Dim oRootDSE, DNSDomain, eNumLen, eCountry
Dim objConnection, objCommand, objRecordSet
Dim DN, oUser, msg, eNumber, wshNetwork
Dim objGroup, objMemberOf, strlist, arrGroup

'*** define vars
Set WshNetwork = CreateObject("WScript.Network")
Set oRootDSE = GetObject("LDAP://RootDSE")
DNSDomain = oRootDSE.Get("DefaultNamingContext")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

'*** start search
objCommand.CommandText = "SELECT distinguishedName FROM 'LDAP://" & DNSDomain & "' " & "WHERE objectCategory = 'user' " & "AND SAMAccountName = '" & eNumber & "'"
Set objRecordSet = objCommand.Execute
On Error Resume Next
objRecordSet.MoveFirst
If Err.Number <> 0 Then
eNumLen = Len(document.getElementByID("inputEnum").value)
If eNumLen < 2 Then
 document.getElementByID("inputName").value = "Please give your login"
Else
 document.getElementByID("inputName").value = eNumber & " was not found!"
Err.Clear
End If

On Error GoTo 0
Else
On Error GoTo 0
Do Until objRecordSet.EOF
DN = objRecordSet.Fields("distinguishedName").Value
Set oUser = GetObject("LDAP://" & DN)

document.getElementByID("inputEnum").value = "" & oUser.SamAccountName
document.getElementByID("inputName").value = "" & oUser.GivenName  & " " & oUser.sn
document.getElementByID("inputTitle").value = "" & oUser.title
document.getElementByID("inputEmail").innerHTML = "" & "<a href='mailto:" & oUser.mail & "&subject=Attention&body=Please update the following information and send it back to me:'>"& oUser.mail & "</a>"
document.getElementByID("inputMgr").value = "" & oUser.Manager
If document.getElementByID("inputMgr").value = "" Then document.getElementByID("inputMgr").value = "<empty>"
objRecordSet.MoveNext

document.getElementByID("inputGroups").value = ""
objmemberOf = oUser.GetEx("memberOf")
For Each objGroup in objmemberOf
  objGroup = Mid(objGroup, 4, 330)
  arrGroup = Split(objGroup, "," )
  document.getElementByID("inputGroups").value = document.getElementByID("inputGroups").value & arrGroup(0) & vbcrlf
Next


_____________________________

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

http://www.visualbasicscript.com

(in reply to cjwallace)
 
 
Post #: 133
 
 RE: Re: Create User Script - 8/11/2005 2:29:27 AM   
  cjwallace

 

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

Many thanks for the reply. How can i add that into my script?

(in reply to Snipah)
 
 
Post #: 134
 
 RE: Re: Create User Script - 8/15/2005 3:37:47 PM   
  Rioku


Posts: 52
Score: 0
Joined: 1/27/2005
From:
Status: offline
Hello,
I am impressed by the success of this thread. 

This is sort of a side question.  I am trying to insert existing users into security groups.  Also I would like to be able to remove a user and search the list of users in a security group.

The scripts you have going in this thread is beyond my skill level.  If you are interested explaining some basics in working with AD then post here: 
http://www.visualbasicscript.com/m_24862/tm.htm

Thanks and good luck on this thread.

(in reply to cjwallace)
 
 
Post #: 135
 
 RE: Re: Create User Script - 10/27/2005 6:00:46 AM