Need script to enable OCS

Hi,

I need a VB Script which enables ocs for the users for those who are not enabled
in active directory.
LVL 1
mansoornazarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Premkumar YogeswaranAnalyst II - System AdministratorCommented:
0
mansoornazarAuthor Commented:
Any idea, How to run this script Urgent!
0
mansoornazarAuthor Commented:
duplicate
0
Chris DentPowerShell 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?

Chris
' 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

  objRecordSet.MoveNext
Loop

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.