Need script to enable OCS


I need a VB Script which enables ocs for the users for those who are not enabled
in active directory.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Chris DentConnect With a Mentor PowerShell DeveloperCommented:

In VbScript, I can't promise it will work, I don't have OCS, this is based on the script I helped with in the link above.

If you're not sure about the values I'm setting find a user that's already enabled in ADSI Edit and check each of the attribute values I'm using with Put towards the end of the script.

Any questions?

' The OCS Server
Dim strServerName : strServerName = "SomeServer"

' For domain auto-discovery
Dim objRootDSE : Set objRootDSE = GetObject("LDAP://RootDSE")
Dim strLdapPath

' The path to run this script against. By default this is the base of the current domain.
strLdapPath = "LDAP://" & objRootDSE.Get("defaultNamingContext")

' If you want to hard-code an LDAP path, modify and uncomment this value:
' strLdapPath = "LDAP://OU=TESTOU,DC=ocstes,DC=in"

' LDAP Filter to find users who are not OCS enabled. 
' Not (!) msRTCSIP-UserEnabled equal to TRUE (catches FALSE and Not Set).
Dim strLdapFilter : strLdapFilter = "(&(objectClass=user)(objectCategory=person)(!msRTCSIP-UserEnabled=TRUE))"

' Set up the AD search
Dim objConnection : Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Dim objCommand : Set objCommand = Createobject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000

objCommand.CommandText = "<" & strLdapPath & ">;" & _
  strLdapFilter & ";name,distinguishedName;subtree"

Dim objRecordSet : Set objRecordSet = objCommand.Execute

Do Until objRecordSet.EOF

  ' Get the  user

  Dim objUser : Set objUser = GetObject("LDAP://" & objRecordSet.Fields("distinguishedName").Value)

  ' For testing the script
  WScript.Echo "Enabling: " & objUser.Get("name")

  ' Set the properties for OCS

  objUser.Put "msRTCSIP-ArchivingEnabled", 0
  objUser.Put "msRTCSIP-FederationEnabled", True
  objUser.Put "msRTCSIP-InternetAccessEnabled", True
  objUser.Put "msRTCSIP-OptionFlags", 257
  objUser.Put "msRTCSIP-PrimaryHomeServer", strServerName
  objUser.Put "msRTCSIP-PrimaryUserAddress", "sip:" & objUser.Get("mail")
  objUser.Put "msRTCSIP-UserEnabled", True

  ' Apply the changes - Note this is commented out while the script is tested

  ' objUser.SetInfo

  Set objUser = Nothing


Open in new window

Premkumar YogeswaranAnalyst II - System AdministratorCommented:
mansoornazarAuthor Commented:
Any idea, How to run this script Urgent!
mansoornazarAuthor Commented:
All Courses

From novice to tech pro — start learning today.