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  1 [2] 3 4 5   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Re: Create User Script - 6/16/2005 3:50:20 AM   
  cjwallace

 

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

I did indeed change it mate

(in reply to cjwallace)
 
 
Post #: 21
 
 Re: Create User Script - 6/16/2005 6:25:47 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
I am i missing something really simple here? i have been all over this scrit but cant quite get it to work

(in reply to cjwallace)
 
 
Post #: 22
 
 Re: Create User Script - 6/17/2005 1:22:36 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
When do you get the error? Launching the file, clicking on Submit, Clear or Exit? I just copied the code and saved it as an HTA and everything worked for me...

(in reply to cjwallace)
 
 
Post #: 23
 
 Re: Create User Script - 6/27/2005 1:04:55 AM   
  jraisor

 

Posts: 39
Score: 0
Joined: 4/29/2005
From:
Status: offline
Does anyone know what i would need to do to this above mentioned script so it will write the following items as well from input boxes?

General Tab of account----
Description
Office
Phone number

Creating a Case for the Address tab so if a certain office is filled in it will aut populate the Street,City State and Zip

and finally

The organization tab:
Title
Dept
Comapany

and Manager.

If anyone has a script that is similar that has input boxes that includes this info or anyone that can help me out that would be great thanks.

(in reply to cjwallace)
 
 
Post #: 24
 
 Re: Create User Script - 6/27/2005 10:10:44 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
quote:
Originally posted by esnmb

When do you get the error? Launching the file, clicking on Submit, Clear or Exit? I just copied the code and saved it as an HTA and everything worked for me...



Hello mate, sorry its taken me so long to reply.

the error i get is

Line: 61

Char: 1

Error: Table does not exist

Code: 0

Any ideas as to what is going on?

I get this error when i click submit.

Cheers

(in reply to cjwallace)
 
 
Post #: 25
 
 Re: Create User Script - 6/28/2005 6:55:39 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Take out this entire section and see if it works. This checks to see if the user name is in AD already before attempting to create the account:




Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText = _
"<GC://dc=DOMAIN,dc=com>;(&(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

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

(in reply to cjwallace)
 
 
Post #: 26
 
 Re: Create User Script - 6/28/2005 9:52:43 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
That worked a treat. Thanks very much the script now runs through.

I have a small issue. I would like the user principalname to automatically put in the users username in before the @withers.net

Set objOU = GetObject("LDAP://OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
Set objUser = objOU.Create("User", "cn=" & strUser)
objUser.Put "sAMAccountName", LCase(strUser)
objUser.Put "userPrincipalName", "@withers.net"
objUser.SetInfo


This is the whole code so far.

<html>
<HTA:APPLICATION
APPLICATIONNAME="Account Creation"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
<head>
<title>User Account Creation Form</title>
<style type="text/css">
<!--
.style3 {font-size: 13px}
body,td,th {
font-family: Arial, Helvetica, sans-serif;
}
.style2 { font-family: Arial, Helvetica, sans-serif;
font-size: 13.5pt;
color: #CC6600;
font-weight: bold;
}
.style5 {font-size: small; color: #FF0000; }
.style6 {color: #FF0000}
-->
</style>

<script type="text/vbscript">
Sub CreateAccount

strUser = TextBox0.Value
If strUser = "" Then
MsgBox "You're missing required fields.",64, "Alert"
Exit Sub
End If

strFirst = TextBox1.Value
If strFirst = "" Then
MsgBox "You're missing required fields",64, "Alert"
Exit Sub
End If

strInitial = TextBox2.Value

strLast = TextBox3.Value
If strLast = "" Then
MsgBox "You're missing required fields",64, "Alert"
Exit Sub
End If

strDisplay = strFirst & ", " & strLast

Const ADS_UF_ACCOUNTDISABLE = 2
Const ADS_PROPERTY_UPDATE = 2

Set objOU = GetObject("LDAP://OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")
Set objUser = objOU.Create("User", "cn=" & strUser)
objUser.Put "sAMAccountName", LCase(strUser)
objUser.Put "userPrincipalName", "@withers.net"
objUser.SetInfo

objUser.Put "givenName", strFirst

If strInitial <> "" Then
objUser.Put "initials", strInitial
End If

objUser.Put "sn", strLast
objUser.Put "displayName", strDisplay

objUser.SetPassword "Passw0rd"
objUser.Put "pwdLastSet", 0

intUAC = objUser.Get("userAccountControl")
If intUAC And ADS_UF_ACCOUNTDISABLE Then
objUser.Put"userAccountControl", intUAC Xor ADS_UF_ACCOUNTDISABLE
End If
objUser.SetInfo

End Sub

Sub Reload
Location.Reload(True)
End Sub

Sub bodyLoaded()
window.ResizeTo 600,510 ' WIDTH, HEIGHT
End Sub

</script>
</head>
<body onLoad="bodyLoaded()">
<p><img src="/images/logo.gif" width="189" height="46"></p>
<p class="style2">Account Creation Page.</p>
<table width="289" border="0" align="left">
<tr>
<td width="89"><span class="style5">*</span>Login ID: </td>
<td width="144"><input type="text" name="textbox0"></td>
</tr>
<tr>
<td><span class="style5">*</span>First Name:</td>
<td><input type="text" name="textbox1"></td>
</tr>
<tr>
<td>Middle Initial: </td>
<td><input type="text" name="textbox2"></td>
</tr>
<tr>
<td><span class="style5">*</span>Last Name: </td>
<td><input type="text" name="textbox3"></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p><br>
<input type="button" name="Submit" value="Submit" onClick="CreateAccount">
</p>
<p>The login ID will have an initial password of password. </p>
<p>The new employee will also be requiered to change their password at first logon. </p>
<p class="style3"><span class="style6">*</span> Indicates Required Field</p>
<p>
<input id="reloadbutton" class="button" type="reset" value="Clear Form" name="reload_button" onClick="Reload">
</p>
<p>
<input type="button" value=" Exit " name="close_button" onClick="Self.Close">
</p>
</body>
</html>

(in reply to cjwallace)
 
 
Post #: 27
 
 Re: Create User Script - 6/29/2005 12:56:57 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
I believe you could just use this

objUser.Put "userPrincipalName", strUser & "@withers.net"

(in reply to cjwallace)
 
 
Post #: 28
 
 Re: Create User Script - 6/29/2005 4:04:30 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
You are the man that worked a treat.

Thanks mate

(in reply to cjwallace)
 
 
Post #: 29
 
 Re: Create User Script - 6/29/2005 4:09:06 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Ok my next issue is this. i have put "cn=" & strUser in to
("LDAP://"cn=" & strUser,OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")

but when run it i get

Line: 93

Char: 15

Error: Expected ')'

I have put a ) all over the place trying to get it to work but it wont take it.

Any ideas as what i am doing wrong?

' Address Page Information

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

objUser.Put "streetAddress", "16 STREET ADDRESS"
objUser.Put "l", "London"
objUser.Put "postalCode", "POST CODE"
objUser.Put "c", "GB"
objUser.SetInfo


Many thanks for your help

(in reply to cjwallace)
 
 
Post #: 30
 
 Re: Create User Script - 6/29/2005 4:51:22 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
("LDAP://cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")

(in reply to cjwallace)
 
 
Post #: 31
 
 Re: Create User Script - 6/29/2005 7:32:30 AM   
  Xandros

 

Posts: 100
Score: 0
Joined: 6/23/2005
From:
Status: offline
("LDAP://"cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net")

The problem is the double-quotes are unbalanced... remove the second one (immediately after the slashes).

(in reply to cjwallace)
 
 
Post #: 32
 
 Re: Create User Script - 6/29/2005 9:28:07 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hello guys, thanks so much for both your help your comments worked a treat. The script is coming along very nice.

My next issue is i need to create a folder on a remote server and the folder needs to be based on the info in strUser

What i have so far is and i know its wrong:

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

Could you point me in the right direction of how i might do this. As you might have guessed i am new to vb and learning all the time.

Many thanks for your help so far.

(in reply to cjwallace)
 
 
Post #: 33
 
 Re: Create User Script - 6/29/2005 11:28:33 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Its ok guys, i have worked it out

I have set it as follows

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

Thanks to everyone who has helped so far i am sure i will be back with more questions

(in reply to cjwallace)
 
 
Post #: 34
 
 Re: Create User Script - 6/29/2005 11:33:57 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Told you i would be back.

I have in my script

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

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

So as you can see it is going to create the users home drive for me. Great. does anyone know how i can follow on from what i have got to give the user full NTFS permissions to this folder?

(in reply to cjwallace)
 
 
Post #: 35
 
 Re: Create User Script - 6/30/2005 1:12:28 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
There are two tools I've used. One from MS called SubInACL or a more powerful open source tool called SetACL.

Using SetACL, this will give the user Change access.

Set objShell = CreateObject("Wscript.Shell")

strDest = "\\LNFS01\home$\" & strUser
objShell.Run ("SetACL.exe -on """ & strDest & """ -ot file -actn ace " _
& "-ace ""n:YOURDOMAIN\" & strUser & ";p:change""")

Of course you can substitute "change" with "full".

(in reply to cjwallace)
 
 
Post #: 36
 
 Re: Create User Script - 6/30/2005 1:28:52 AM   
  cjwallace

 

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

When i try to run this in my script i get an error:

Line: 162

Char: 1

Error: 'objscript'

I have downloaded setacl and copied it into the windows directory.

Any ideas why its failing?

Many thanks for all your help

(in reply to cjwallace)
 
 
Post #: 37
 
 Re: Create User Script - 6/30/2005 1:31:12 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Look at mine again. I copied part of my code from another script. change objScript to objShell.

(in reply to cjwallace)
 
 
Post #: 38
 
 Re: Create User Script - 6/30/2005 1:35:45 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi esnmb, sorry i must have copied your code before you had a chance to edit it.

Anyway i have changed the script and i now dont get the error but it has not put the user in the ntfs list

Any ideas? have i done something wrong. if you want i can post the whole script for you to look at

Thanks again for your continued help

(in reply to cjwallace)
 
 
Post #: 39
 
 Re: Create User Script - 6/30/2005 1:37:12 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Sure, post the whole thing so I can dig through it.

Does the user dir exist?

(in reply to cjwallace)
 
 
Post #: 40
 
 
Page:  <<   < prev  1 [2] 3 4 5   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Re: Create User Script Page: <<   < prev  1 [2] 3 4 5   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts