Using a script to create user accounts via active directory and also create folders/permissions

Discussion in 'Scripting' started by Writing Implement, Sep 7, 2003.

  1. Hello :)

    I am script and batch file newbie, so bear with me :)

    I'm using Active Directory on a windows 2000 server. What I'm after are
    three separate things:
    1) A way to create lots of user accounts in one go. (this might not be
    possible, as it involves the active directory) This involves creating a
    user, ie 'joe bloggs', assigning a password, assigning a login name,
    and also assigning a login script - which already exists. The user
    accounts in are given the same password to begin with, and then they change
    their password upon logging in.

    2) Create folders on a drive based on the user accounts. A sample folder
    would be 'joe bloggs' with an account name 'joe bloggs', login name of
    'joe.bloggs'. So joe bloggs would have his folder in G$:\users\joe bloggs

    If an account being created happens to have the same name as an existing
    account, I normally add a number 2 on the end, ie 'joe bloggs2' for the
    account name and 'joe.bloggs2' for the login name - the same goes for the
    folder on G$:\users: G$:\users\joe bloggs2

    3) Each folder then needs to be given permissions. Or rather, remove
    permissions on each folder other than 'joe bloggs' (in this case).
    When the folder is first made, there arepermissions for 'everyone' and
    'administrator' that need to be removed. Joe Bloggs must then have
    all rights to only the 'joe bloggs' folder.

    There are existing users folders, so naturally they cannot be deleted.


    Writing Implement :)
    Writing Implement, Sep 7, 2003
    1. Advertisements

  2. Hi,

    I've seen several similar requests recently, so I decided to post a sample
    VBScript program on my web site to create users in bulk from the information
    in an Excel spreadsheet:

    It's much easier to put intelligence in the spreadsheet. You can make some
    cells functions of the values in other cells. You can easily copy values or
    formulas from one user to others. I have not added code to handle duplicate
    names, but the resulting error is trapped and a message echoed to the user
    that the user object could not be created. Everyone handles duplicates

    The program is basic with few bells and whistles, but should get you
    started. The code expects a UNC path for home folder. For example
    "\\MyServer\Users\JSmith", where "MyServer" is the server, "Users" is the
    share, and "JSmith" is the home folder. It is assumed that the share "Users"
    is already created. The group "Everyone" should be removed and the group
    "Domain Administrators" added to the security tab for the "Users" folder
    before the program is run. The program grants the user full permission to
    their home folder, "JSmith" in this case. The program also creates it, but
    only if it does not exist.

    Such a program can take awhile to create a large number of users. Similar
    programs take about 0.33 sec/user on a 500 MHz machine, and 2.5 sec/user on
    a 100 MHz machine. Any feedback appreciated.
    Richard Mueller [MVP], Sep 9, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.