Tuesday, March 1, 2011

Automatically Create Active Directory Accounts for Microsoft OCS

In order to load test one of our Microsoft OCS applications, we needed to quickly create hundreds of test accounts for one of our OCS servers.  First, we created the accounts in AD, then we simply highlighted the new accounts and provisioned the accounts for our OCS server.

Here is a small vbs script to create the sample users:

Set oRoot = GetObject(LDAP://rootDSE)

Set oDomain = GetObject("LDAP://" & oRoot.Get("defaultNamingContext"))
Set oOU=oDomain.Create("organizationalUnit", "ou=OCS Test Users")
oOU.Put "Description", "OCS Test Users"
oOU.SetInfo

For i = 1 to 200


       Set oUser = oOU.Create("User", "cn=OCSTest User" & i)
       oUser.Put "sAMAccountName", "OCSTestUser" & i
       oUser.Put "Description", "OCS Test User" & i
       oUser.SetInfo
       oUser.SetPassword "password"
       oUser.AccountDisabled = False
       oUser.SetInfo


Next

Wscript.Echo "Success, Check Active Directory Users and Computers - Remember F5"

Here is a screen shot of the test users:














After selecting all of the users in the explorer, we used the action to automatically provision the users for OCS - and selected the 'use SAM account' option