Archive

Posts Tagged ‘OCS 2007’

VB Script to Create Office Communication Server Enabled Users in Active Directory

July 3rd, 2009 No comments

Following is a VB Script to create Office Communication Server Enabled users in Active Directory.


Option Explicit
Dim strUser, strPassword, strName, strDomain, strADRoot
Dim strUCPool, strDC, intStart, intEnd
Dim objRootLDAP, objContainer, objNewUser

strUser = "ocsuser"
strName = "OCS User"
strDomain = "asinghal.com"
strPassword = "pass2004"
strADRoot = "LDAP://cn=Users,DC=asinghal,dc=com"
strUCPool = "<OCS-Pool-Name>"
strDC = "DC=asinghal,DC=com"
intStart = 53
intEnd = 150

const ADS_UF_DONT_EXPIRE_PASSWD = &H10000

' Bind to Active Directory, Users container.
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject(strADRoot)

' Build the actual User.
Dim count
For count = intStart To intEnd
 Set objNewUser = objContainer.Create("User", "cn=" & strUser & count)
 objNewUser.Put "sAMAccountName", strUser & count
 objNewUser.Put "givenName", strName & count

 'Enable following parameter if you want to enable this user for Unified Communication
 objNewUser.Put "msRTCSIP-InternetAccessEnabled", TRUE
 objNewUser.Put "msRTCSIP-ArchivingEnabled", 0
 objNewUser.Put "msRTCSIP-FederationEnabled", FALSE
 objNewUser.Put "msRTCSIP-OptionFlags", 256
 objNewUser.Put "msRTCSIP-PrimaryHomeServer", "CN=LC Services,CN=Microsoft,CN=" &
            strUCPool & ",CN=Pools,CN=RTC Service,CN=Microsoft,CN=System," & strDC
 objNewUser.Put "msRTCSIP-PrimaryUserAddress", "sip:" & strName & count
            & "@" & strDomain
 objNewUser.Put "msRTCSIP-UserEnabled", TRUE
 'UC Properties Ends

 objNewUser.SetInfo
 objNewUser.SetPassword strPassword
 objNewUser.Put "userAccountControl", 512 XOR ADS_UF_DONT_EXPIRE_PASSWD
 objNewUser.SetInfo
Next
WScript.Quit

' End of free sample Create Users VBScript.