Poll: Will you find this or a future version of this script useful?

Be advised that this is a public poll: other users can see the choice(s) you selected.

+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
Scripts Thread, AD Bulk User Importer in Coding and Web Development; Ok I have been promising to produce something like this so after the morning gardening this has been my therapy ...
  1. #1
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,938
    Thank Post
    114
    Thanked 272 Times in 250 Posts
    Rep Power
    104

    AD Bulk User Importer

    Ok I have been promising to produce something like this so after the morning gardening this has been my therapy :P

    This is a GUI front end for a script I produced in VB script last year.

    The full features of the original script included:

    Import information from a CSV file.
    UserName generation.
    Creation of home directories and setting of permission and ownership (Using cacls and the windows version of CHOWN)


    **** The author takes no responsibility for any damage that could be caused by this script USE AT YOUR OWN RISK!!!!!!!!! ****

    Current version 1.0


    This must be run on a Windows XP machine that is a member of a domain
    At the moment it will read the following information from a CSV file (in this order)
    Surname, First Name, UserName, Password

    It is also assumed that the OU already exists and you must specify a group
    that must be in the same OU as the users are going. This will be made more flexible later


    As I gradually migrate the code over I will be adding the following features:

    Add more fields to be inputed through the GUI such as:
    home drive path, home drive letter
    Other functions to include the creation of home directory and setting ownership and permissions.
    Username generation.
    Smarten up the HTML so it doesnt look like a year 7 produced it :P

    Edit 05/05/2006

    Ok its looking quiete good now. The error checking is mostly in and seems to work ok. Check out the avi on the second page. I have also added a visual log.

    I will post the current version once I have got rid of a few bugs

  2. #2
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,938
    Thank Post
    114
    Thanked 272 Times in 250 Posts
    Rep Power
    104

    Re: AD Bulk User Importer

    Oh and any comments or suggestions are welcomed.

  3. #3

    Dos_Box's Avatar
    Join Date
    Jun 2005
    Location
    Preston, Lancashire
    Posts
    9,467
    Thank Post
    524
    Thanked 1,993 Times in 932 Posts
    Blog Entries
    23
    Rep Power
    575

    Re: AD Bulk User Importer

    Thtas fantastic, Thanks Chris, I'm sure some people will prettify and expand it quite rapidly!!

  4. #4
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,938
    Thank Post
    114
    Thanked 272 Times in 250 Posts
    Rep Power
    104

    Re: AD Bulk User Importer

    I have most of the code already to slot in. It will just need a little rearranging. The only thing I would have to write from scratch would be the username generation routine as mine is hard coded to our naming scheme but that shouldnt be too hard.

  5. #5
    mark's Avatar
    Join Date
    Jun 2005
    Posts
    3,945
    Thank Post
    233
    Thanked 48 Times in 44 Posts
    Blog Entries
    2
    Rep Power
    45

    Re: AD Bulk User Importer

    Wowser! Thanks Chris - will test it out and give some feedback soon.

  6. #6
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,938
    Thank Post
    114
    Thanked 272 Times in 250 Posts
    Rep Power
    104

    Re: AD Bulk User Importer

    Good good. The test button on the OU field isnt implemented yet btw.

  7. #7
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    41

    Re: AD Bulk User Importer

    Nice one i can make changes to mine so its hta too or make changes to yours. Thanks for this.

  8. #8
    sahmeepee's Avatar
    Join Date
    Oct 2005
    Location
    Greater Manchester
    Posts
    795
    Thank Post
    20
    Thanked 69 Times in 42 Posts
    Rep Power
    33

    Re: AD Bulk User Importer

    ChrisH:
    I made a single-user vbscript which did this sort of thing all-in-one so that I didn't have to mess around when a new pupil came to the school in the middle of a school year. It's quite handy for quickly creating test accounts too.

    On top of the basics, it made the home folder, set permissions on it and created a share on it (as well as setting all the properties of their account I needed e.g. group memberships*). I did some bits of it by calling cacls.exe and rmtshare.exe with WshShell.Run rather than pure VB, because I didn't have any great plans on distributing it to anyone else.

    The only thing I never got round to was creating their mailbox in Exchange, because that needed more advanced veebee voodoo. If I look at it again, I'll probably use this:
    http://www.joeware.net/win/free/tools/exchmbx.htm
    because laziness generally wins against elegance!

    If you want the code, PM me - it's so heavily customised for our particular setup that it wouldn't be much use as a starting point for people, but you might be able to lift bits you like.

    One feature request would be to let the csv file have column headers, so that you could make some parameters optional. It's worth bearing in mind though that a lot of properties of user accounts can be done in bulk in WS2003's ADUC by multi-selecting so there's not much of a time-saving aspect after you consider that you have to generate the csv file in the first place.

    *yes, I know that isn't technically a property of the user account!

  9. #9
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,938
    Thank Post
    114
    Thanked 272 Times in 250 Posts
    Rep Power
    104

    Re: AD Bulk User Importer

    My original script that is fully working is much the same as yours. I used cacls for permissions and the the windows version of CHOWN for ownership.
    I didnt even think about Exchange thought so I will put that on list.
    That is a good suggestion about the column headers for the CSV file I do have them currently on the version I am using but they are more of a guide when you first start putting data into it. I will make it more intelligent though as you suggested.

    The thing im struggling on at the moment is the error trapping. To check the existence of a user an object in AD I use something like this:

    Code:
    Set ObjParent = Getobject (OUPath) 'Get the container
    MsgBox Err.Number
    If Err.Number <> 0 Then
    	CheckOUExists = False
    Msgbox "The OU was not found try again"
    	Else
    CheckOUExists = True
    MsgBox "OU Exists"
    	Err.Clear
    End If 'Error handling
    This works fine in a VB script but put the when ran this way it doesnt like it and it comes up with a Internet Explorer error. Using "On Error Resume Next" doesnt work in this context either.

    Can someone enlighten me as to what kind of construct I need to use.

    Cheers

    Chris

  10. #10
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,938
    Thank Post
    114
    Thanked 272 Times in 250 Posts
    Rep Power
    104

    Re: AD Bulk User Importer

    I have found a temporary answer by suppressing the error with some JScript:

    Code:
    <script type="text/javascript">
    <!-- //
    
    function handleError() {
    	return true;
    }
    
    window.onerror = handleError;
    //-->
    </script>
    Need something better though

    EDIT:

    Ok its looking like error checking needs to be done is JS I think?
    Does anyone have any input on this?
    (and I thought this was going to be a simple transition )

  11. #11
    sahmeepee's Avatar
    Join Date
    Oct 2005
    Location
    Greater Manchester
    Posts
    795
    Thank Post
    20
    Thanked 69 Times in 42 Posts
    Rep Power
    33

    Re: AD Bulk User Importer

    This page:

    http://msdn.microsoft.com/library/de...WebErrors2.asp

    says:

    Handling window.onerror in VBScript

    With two exceptions, everything I just told you about handling the window.onerror event in pages scripted with JavaScript applies equally to those scripted with VBScript. The first difference is the exact syntax for indicating a window.onerror handler in VBScript:

    Code:
    <SCRIPT language="VBScript">
    Function window_onerror ( message, url, line )
        window_onerror = true
    End Function
    </SCRIPT>
    As you can see, the VBScript syntax for installing an event handler requires naming a function in the convention object_event. In this case we want to install a handler for the onerror event on the window object, so we create a VBScript function named window_onerror. Also, in VBScript, return values are indicated by assignment to a variable named after the function.
    I haven't tested that, so caveat scriptor, but I guess you could use the stuff on that page to pull some information out about the error and process it.

  12. #12
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,938
    Thank Post
    114
    Thanked 272 Times in 250 Posts
    Rep Power
    104

    Re: AD Bulk User Importer

    Thanks I had got halfway there by having it generate a generic error but just needed to pass "message" to the function so it came up with the proper error which it seems to be doing quite well.
    Oh well least I learned something new today

  13. #13
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,938
    Thank Post
    114
    Thanked 272 Times in 250 Posts
    Rep Power
    104

    Re: AD Bulk User Importer

    Ok I have made a slight update. I have updated the code and the download above.

    I have added fields for a group to add the users to and given the option to disable users on creation.
    You can also now choose an OU at any depth as long as you specify the path.
    If you have a top level OU called students and a year7 OU in there then you must type in

    Code:
    year7,students
    No space either side of the comma. So basically your working your way backwards to the top level. If you press test it will check of the OU exists and display the LDAP path to you.

    I'm still working on the error correction as it seems I have to use java script for this which I wasnt expecting (if anyone knows better let me know)

    This can break in several parts including:
    The OU doesnt exist or you types the path wrong.

    The group field is left blank (You must put something at the moment).

    The group object is not in the same place as the users are going to (will make that more flexible later).

    The user objects already exist.

    The code might be a bit sloppy in places but I will tidy up once everything is working.

    Enjoy

    Comments welcomed

  14. #14
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,938
    Thank Post
    114
    Thanked 272 Times in 250 Posts
    Rep Power
    104

    Re: AD Bulk User Importer

    Right well after seeing the code for another HTA which was using normal VBS error control I thought wtf!!! I then realised shortly before kicking myself very hard that the reason the error checking was not working was because all of my VB code was in Functions and Subs so my On error resume next statement that I had just plonked above them all had no effect ops:
    So this is much better for me and will spend some time on it tommorow and release something a little prettier with more functionality and more inportant a little more stable

  15. #15
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,938
    Thank Post
    114
    Thanked 272 Times in 250 Posts
    Rep Power
    104

    Re: AD Bulk User Importer

    Ok this is going along nicely at the moment. All the error checking code is working nicely and I have a visual log that runs as the script executes. I havent updated the first post as I still have a few more bugs to iron out.
    I am attaching a html file with a mock up of the interface. If anyone wants to mess around with the styles and make it look a bit better then please be my guest (so I can concentrate on the coding ) . Just makes sure it fits within the current width dimensions of the left and right content divs.

    Once I get this running to my satisfaction I will work on the next phase which will be more intelligent routines from reading from the CSV file. This will involve a first screen where you select the file and it reads the column headers. It will then on the second screen add the common fields that arent accounted for in the CSV file.
    This will allow more flexibility to allow different values for fields like description read in from the file or the same for all if input from the GUI.

    PS I just noticed its broken under firefox as it's been running under a HTA in an explorer process I didnt notice :P
    Attached Files Attached Files

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Active Directory - Single and Bulk User creation and FREE!!
    By siuko in forum How do you do....it?
    Replies: 39
    Last Post: 20th June 2012, 11:29 AM
  2. Bulk user Creation
    By Jamie_a in forum Windows
    Replies: 10
    Last Post: 14th January 2009, 06:30 PM
  3. Bulk User Creation Tools
    By mark in forum Downloads
    Replies: 16
    Last Post: 10th July 2007, 04:24 PM
  4. Edit user accounts in bulk
    By edsa in forum Windows
    Replies: 10
    Last Post: 21st June 2007, 09:39 PM
  5. Bulk user creation
    By Dos_Box in forum How do you do....it?
    Replies: 63
    Last Post: 13th November 2006, 07:02 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •