This week I’ve had the need to do some testing around ADAM (also known by it’s shiny new name of Active Directory Lightweight Directory Services or AD LDS). The tests themselves are not directly relevant to this blog post, but in order for the tests to have some validity the ADAM instance needed to be a larger than the default install.
In the absence of a nice bulky backup or other directory instance to take previously created objects from I needed a quick method to bulk that bad boy up. This can be useful in creating objects and monitoring as they replicate among your instance replicas, testing for scaling of your ADAM back end solution given your hardware and network topology.
When I looked around for some pre existing script which could do what I needed I found plenty of scripts….but none that could do the trick in a small number of iterations.
The best script repositories for ADAM that I could find are the original “Madam, I’m ADAM” article and The Script Center . But none of these were made with the intention of creating a high volume of arbitrarily named objects. So a little bit of thought was required (unfortunately).
There are different ways to provide named object creation in that way, but the only ones I could think of offhand used a “for” loop. Rather than providing an “answer” file of names to pipe into the script I tried to keep it simple and put the for loop within the script and instantiated a variable i to do the job.
Here’s the script, which is set to create 100,000 user class objects.
'**************************************************
' This script adds i = n users to a specified OU or CN.
' Alter as needed.
'**************************************************
' If the application NC DN is "ou=adamou,c=us" and the server is "adamhost" and the port is 389. Then the parameter 'OUName should be passed
' as follows: "LDAP://adamhost:389/ou=adamou,c=us"
Set ou = GetObject("LDAP://localhost:389/OU=Users,DC=treyresearch,DC=com")
For i = 1 To 100000
set usr = ou.Create("user", "cn=" & "Test" & i)
usr.Put "displayName", "Test" & i
usr.Put "userPrincipalName", "Test" & i & "@treyresearch.com"
usr.SetInfo
Next
wscript.echo "100000 users created successfully"
Just call the script from command line using cscript.exe.
After the script runs you should have a container or organizational unit with stuff in it…
and consequently a larger ADAM database file (in the case below about a million user objects added)…
A few ‘scripting for ADAM’ caveats came up whilst doing this. Some are documented in various places, others may not be so I”m putting them here for all to see.
set usr = ou.Create("user", "cn=" & "Test" & i)
to the class object you need, alter the usr.Put verb to match, and make sure you pass in the info that different class needs.
Hopefully this will help out people who are in a “proof of concept” or other testing phase and need to bulk that directory up in a hurry.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.