Guy's Scripting Ezine 13 - Creating Users
Guy's Scripting Ezine No 13 - Creating Users with VBScript
Contents of Creating Users with VBScript
I am on the 'horns of a dilemma'; how long should I make this Ezine? There is much that I want to say about LDIFDE and even more that I want tell you about VBScript. One solution is to create an ebook called 'How to Create Users using VBScript'. The other solution is to make the Ezine longer.
Guy Recommends: The Free IP Address Tracker (IPAT)
Calculating IP Address ranges is a black art, which many network managers solve by creating custom Excel spreadsheets. IPAT cracks this problem of allocating IP addresses in networks in two ways:
For Mr Organized there is a nifty subnet calculator, you enter the network address and the subnet mask, then IPAT works out the usable addresses and their ranges.
For Mr Lazy IPAT discovers and then displays the IP addresses of existing computers. Download the Free IP Address Tracker
VBScript is so versatile and widespread that it is becoming a required skill for Window Server 2003 and 2000 administrators. My point is that tips and techniques you learn when creating users can be applied to other areas, such as, scripts for interrogating the Event Logs, or scripts for changing the registry.
Our goal this week is to build a script that will create new users in your Active Directory domain.
Method 1 works like mail-merge. An Excel spreadsheet holds the data, while a VBScript reads the users' properties, and then creates the user object in Active Directory. A bonus of this method is that spreadsheet acts as a record for who you have added to your domain.
The script needs a 'Loop' to read the properties from each row and so generate a succession of new users. I have a section in the ebook explaining Do... Until Loop routines.
The crucial feature of the spreadsheet is the first row which holds the LDAP properties for the users. This similar to creating field names for a database. A key skill is to deduce the LDAP names which correspond to the user properties; for example the LDAP name for First Name is givenName.
Now, I have a brand new ebook which has a great script to create users. What you get in the ebook are step-by-step instructions to customize the example script to suit your own domain. You also get a excel spreadsheet with LDAP properties in the first row. The ebook is divided into 10 sections each page explains a feature of the script in detail. Check out the ebook content here.
Each week I like to include at least one script for you to copy, paste and modify. The strength of this week's script is that it will create users in any domain. Its statements are designed to get you started in your quest to script new user accounts. One weakness is that it does not read from a spreadsheet, whereas the script in the ebook opens excel and extracts the LDAP properties.
' VBScript to create an OU called BulkGuy
You may remember that last week I mentioned 6 ways of creating scripts?
This week's focus is on the benefits and weaknesses of LDIFDE. If it were in my football team I would have LDIFDE in my 'Special Team' unit.
Firstly the acronym LDIFDE means LDIF Data Exchange. If your wondering what LDIF stands for it is - Lightweight Data Interchange Format. In a nutshell the acronym is telling us that this program is about moving data between systems which store data in different structures.
LDIFDE is much like CSVDE. Both are built-in commands in Server 2003 and Windows 2000, and both need a file to exchange data with Active Directory.
The killer advantage of LDIFDE is that you can modify or delete existing objects. Another advantage is that LDIFDE will let you change users passwords.
The disadvantage of LDIFDE is that it does not 'feed off' spreadsheets, and I find the format a bit clunky. See more about LDIFDE here.
VBScript is becoming an essential skill for anyone who has to look after Windows 2000 or 2003 servers. In this Ezine we have a great example of a VBScript to create users in Active Directory.
One our weekly theme of running through all the available tools, we have a quick look at LDIFDE.
See More Active Directory VBScripts to Create Users