ActiveXperts.com » Administration » Scripts » Adsi » Create a new Group object - vbscript

Create a new Group object - vbscript

Active Directory Services Interface (ADSI) is a set of COM (Common Object Model) programming Interfaces. Like ODBC, ADSI provides common access to directories by adding a provider for each directory protocol type.

You can use any of the VBScript programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.

On this site, you can find many ADSI samples.

The create-a-new-group-object ADSI class can be used in ActiveXperts Network Monitor to monitor your servers.


Example(s)

ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
ADS_GROUP_TYPE_LOCAL_GROUP = &h4
ADS_GROUP_TYPE_UNIVERSAL_GROUP = &h8
ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000

strContainer = ""
strName = "EzAdGroup"

'***********************************************
'*         Connect to a container              *
'***********************************************
Set objRootDSE = GetObject("LDAP://rootDSE")
If strContainer = "" Then
  Set objContainer = GetObject("LDAP://" & _
    objRootDSE.Get("defaultNamingContext"))
Else
  Set objContainer = GetObject("LDAP://" & strContainer & "," & _
    objRootDSE.Get("defaultNamingContext"))
End If
'***********************************************
'*       End connect to a container            *
'***********************************************

Set objGroup = objContainer.Create("group", "cn=" & strName)
objGroup.Put "sAMAccountName", strName
objGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP Or _
  ADS_GROUP_TYPE_SECURITY_ENABLED
objGroup.SetInfo
M