Re: create account

Tech-Archive recommends: Speed Up your PC by fixing your registry




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




.



Relevant Pages

  • Re: Local account creation
    ... While this script works fine for my 2003 environment, ... use the script in a startup GPO so that there a generic local admin account ... Dim objNetwork, strComputer, strUser ...
    (microsoft.public.windows.server.scripting)
  • Re: create account
    ... i have created a script to create an account by manuely inserting the ... strUser = newuser. ... manuelly inserting the strmember,& strOuList2. ... i would like the script to copy membership from strmember to strUser ...
    (microsoft.public.scripting.vbscript)
  • create account
    ... i have created a script to create an account by manuely inserting the ... strUser = newuser. ... manuelly inserting the strmember,& strOuList2. ...
    (microsoft.public.scripting.vbscript)
  • Protecting against dDOS bots (was: Newbie php problem)
    ... The form mail script posted that was used, ... requires the applicant to pass some kind of Turing test, ... Turing test if the account balance ever drops to zero. ... Log into the same account repeatedly, which consumes your credit ...
    (alt.php)
  • Re: Entourage account setup applescript not working
    ... I pasted the script at the end just in case. ... When comparing the account settings on 2 computers, ... This script assists a user with the setup of his Exchange account ... Customize the network and server properties below with information ...
    (microsoft.public.mac.office.entourage)