Re: create account
- From: "Al Dunbar" <AlanDrub@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 12 Aug 2008 16:08:43 -0600
"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> wrote in
message news:%23sd0NGJ$IHA.4616@xxxxxxxxxxxxxxxxxxxxxxx
deen wrote:
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
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
.
- References:
- create account
- From: deen
- Re: create account
- From: Richard Mueller [MVP]
- create account
- Prev by Date: Re: Progress Status
- Next by Date: Re: Script to delete a specific profile on all workstations
- Previous by thread: Re: create account
- Next by thread: VBScript and CDOSYS
- Index(es):
Relevant Pages
|