Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - create account

Reply
 
Old 08-12-2008   #1 (permalink)
deen


 
 

create account

PLease help.
i have created a script to create an account by manuely inserting the
OU Location

strUser = newuser.
strOuList = OU=*************,DC=***********,DC=***********,DC=COM

i having trouble manuely inserting the strUser and strOuList and
manuelly inserting the strmember(similar user),& strOuList2.

i would like the script to copy membership from strmember to strUser

If strmember = "" Then
MsgBox "You're missing required fields",64, "Alert"
Exit Sub
End If

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

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

Set objUser1 = GetObject("LDAP://CN=" & strmember "," & strOuList2)
Set objUser2 = GetObject("LDAP://CN=" & strUser "," & strOuList)

For Each objGroup In objUser1.Groups
If (objGroup.IsMember(objUser1.AdsPath) = False) Then
objGroup.Add(objUser2.AdsPath)
END IF
Next



My System SpecsSystem Spec
Old 08-12-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: create account

deen wrote:
Quote:

> PLease help.
> i have created a script to create an account by manuely inserting the
> OU Location
>
> strUser = newuser.
> strOuList = OU=*************,DC=***********,DC=***********,DC=COM
>
> i having trouble manuely inserting the strUser and strOuList and
> manuelly inserting the strmember(similar user),& strOuList2.
>
> i would like the script to copy membership from strmember to strUser
>
> If strmember = "" Then
> MsgBox "You're missing required fields",64, "Alert"
> Exit Sub
> End If
>
> strOuList2 = TextBox10.Value
> If strOuList2 = "" Then
> MsgBox "You're missing required fields.",64, "Alert"
> Exit Sub
> End If
>
> ======================================================================
>
> Set objUser1 = GetObject("LDAP://CN=" & strmember "," & strOuList2)
> Set objUser2 = GetObject("LDAP://CN=" & strUser "," & strOuList)
>
> For Each objGroup In objUser1.Groups
> If (objGroup.IsMember(objUser1.AdsPath) = False) Then
> objGroup.Add(objUser2.AdsPath)
> END IF
> Next
>
You can hard code values in the script, in which case you must edit the
script every time you use it, or you can pass parameters to the script, or
you can have the script prompt for values. If you pass parameters to the
program on the command line use the Wscript.Arguments collection to access
them in your program. For example, if the VBScript program is called
CreateUser.vbs, you can pass strUser, strMember, strOUList, and strOUList2
as parameters with a command line similar to:

cscript CreateUser.vbs JimSmith, MaryWilson, "ou=West,dc=MyDomain,dc=com",
"ou=East,dc=MyDomain,dc=com"

Then in the script use Wscript.Arguments to access the parameters. For
example:
========
If (Wscript.Arguments.Count <> 4) Then
Wscript.Echo "Arguments missing"
Wscript.Quit
End If

strUser = Wscript.Arguments(0)
strMember = Wscript.Arguments(1)
strOUList = Wscript.Arguments(2)
strOUList1 = Wscript.Arguments(3)
=======
The arguments must be provided in the correct order. Or, it might make more
sense to have the program prompt for values, using the InputBox function.
For example:
=========
strUser = InputBox("Enter Common Name of new user", "Create User")
strOUList = InputBox("Enter DN OU where new user will be created", "Create
User")
strMember = InputBox("Enter Common Name of template user to copy group
memberships", "Create User")
strOUList2 = InputBox("Enter DN of OU of template user", "Create User")

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 08-12-2008   #3 (permalink)
Al Dunbar


 
 

Re: create account


"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in
message news:%23sd0NGJ$IHA.4616@xxxxxx
Quote:

> deen wrote:
>
Quote:

>> PLease help.
>> i have created a script to create an account by manuely inserting the
>> OU Location
>>
>> strUser = newuser.
>> strOuList = OU=*************,DC=***********,DC=***********,DC=COM
>>
>> i having trouble manuely inserting the strUser and strOuList and
>> manuelly inserting the strmember(similar user),& strOuList2.
>>
>> i would like the script to copy membership from strmember to strUser
>>
>> If strmember = "" Then
>> MsgBox "You're missing required fields",64, "Alert"
>> Exit Sub
>> End If
>>
>> strOuList2 = TextBox10.Value
>> If strOuList2 = "" Then
>> MsgBox "You're missing required fields.",64, "Alert"
>> Exit Sub
>> End If
>>
>> ======================================================================
>>
>> Set objUser1 = GetObject("LDAP://CN=" & strmember "," & strOuList2)
>> Set objUser2 = GetObject("LDAP://CN=" & strUser "," & strOuList)
>>
>> For Each objGroup In objUser1.Groups
>> If (objGroup.IsMember(objUser1.AdsPath) = False) Then
>> objGroup.Add(objUser2.AdsPath)
>> END IF
>> Next
>>
>
> You can hard code values in the script, in which case you must edit the
> script every time you use it, or you can pass parameters to the script, or
> you can have the script prompt for values. If you pass parameters to the
> program on the command line use the Wscript.Arguments collection to access
> them in your program. For example, if the VBScript program is called
> CreateUser.vbs, you can pass strUser, strMember, strOUList, and strOUList2
> as parameters with a command line similar to:
>
> cscript CreateUser.vbs JimSmith, MaryWilson, "ou=West,dc=MyDomain,dc=com",
> "ou=East,dc=MyDomain,dc=com"
>
> Then in the script use Wscript.Arguments to access the parameters. For
> example:
> ========
> If (Wscript.Arguments.Count <> 4) Then
> Wscript.Echo "Arguments missing"
> Wscript.Quit
> End If
>
> strUser = Wscript.Arguments(0)
> strMember = Wscript.Arguments(1)
> strOUList = Wscript.Arguments(2)
> strOUList1 = Wscript.Arguments(3)
> =======
> The arguments must be provided in the correct order. Or, it might make
> more sense to have the program prompt for values, using the InputBox
> function. For example:
> =========
> strUser = InputBox("Enter Common Name of new user", "Create User")
> strOUList = InputBox("Enter DN OU where new user will be created", "Create
> User")
> strMember = InputBox("Enter Common Name of template user to copy group
> memberships", "Create User")
> strOUList2 = InputBox("Enter DN of OU of template user", "Create User")
Instead of requiring the user to enter the CN and DN of containing OU for
the account to be created and the template account to use, why not ask for:

- CN of account to be created
- sAMAccountName of template account
- sAMAccountName of an account in the OU where the new account is to be
created if different from the template account

and then determine the DN's of the account(s) and their OU's by applying
NAMETRANSLATE to the sAMAccountNames, and the "parent" attribute of the
account in the target OU?

I'd provide an example, but all my code is at work and my recollection of
the details is woefully poorer than Richard's ;-)

/Al
Quote:

>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Re: Copy a user account & create duplicate account w/new name? Vista General
Cannot Create Fax Account General Discussion
you have to create a fax-account Vista print fax & scan
Help me create my account Vista mail
Cannot create new account. Help! Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46