ActiveXperts Network Monitor
Monitor servers, workstations, devices and applications in your network

Quicklinks


Retrieving ADAM Objects using VBScript

List All ADAM Contact Attributes and Values
List All ADAM Container Attributes and Values
List All ADAM Group Attributes and Values
Lists all the attributes and values for an ADAM inetOrgPersonAccount named Syedabbas.
List All ADAM OU Attributes and Values
List All ADAM OUs
List All ADAM User Attributes and Values
List the ADAM OU Schema
List the ADAM User Schema
List All the Users in an ADAM OU
List All the Members of an ADAM Group
List All the Accounts in an ADAM OU
List All the Groups in an ADAM OU
List All the inetOrgPersons in an ADAM OU
List the ADAM Container Schema
List the ADAM inetOrgPerson Schema
List the ADAM Group Schema
List the ADAM Contact Schema
List the Groups an ADAM User Belongs to
Verify that ADAM is Installed


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.



List All ADAM Contact Attributes and Values


Lists all the attributes and values for the ADAM contact account Alexandrelobao.
On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=alexandrelobao,ou=Accounting,dc=fabrikam,dc=com")
Set objUserProperties = GetObject("LDAP://localhost:389/schema/contact")

For Each strAttribute in objUserProperties.MandatoryProperties
    strValues = objUser.GetEx(strAttribute)
    For Each strItem in strValues
        Wscript.Echo strAttribute & " -- " & strItem
    Next
Next

For Each strAttribute in objUserProperties.OptionalProperties
    strValues = objUser.GetEx(strAttribute)
    If Err = 0 Then
        For Each strItem in strValues
            Wscript.Echo strAttribute & " -- " & strItem
        Next
    Else
        Wscript.Echo strAttribute & " --  No value set"
        Err.Clear
    End If
Next
	

List All ADAM Container Attributes and Values


On Error Resume Next Set objUser = GetObject("LDAP://localhost:389/cn=Users,dc=fabrikam,dc=com") Set objUserProperties = GetObject("LDAP://localhost:389/schema/container") For Each strAttribute in objUserProperties.MandatoryProperties strValues = objUser.GetEx(strAttribute) For Each strItem in strValues Wscript.Echo strAttribute & " -- " & strItem Next Next For Each strAttribute in objUserProperties.OptionalProperties strValues = objUser.GetEx(strAttribute) If Err = 0 Then For Each strItem in strValues Wscript.Echo strAttribute & " -- " & strItem Next Else Wscript.Echo strAttribute & " -- No value set" Err.Clear End If Next
Lists all the attributes and values for the ADAM container named Users.

List All ADAM Group Attributes and Values


Lists all the attributes and values for an ADAM group named Accountants.
On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=Accountants,ou=Accounting,dc=fabrikam,dc=com")
Set objUserProperties = GetObject("LDAP://localhost:389/schema/group")

For Each strAttribute in objUserProperties.MandatoryProperties
    strValues = objUser.GetEx(strAttribute)
    For Each strItem in strValues
        Wscript.Echo strAttribute & " -- " & strItem
    Next
Next

For Each strAttribute in objUserProperties.OptionalProperties
    strValues = objUser.GetEx(strAttribute)
    If Err = 0 Then
        For Each strItem in strValues
            Wscript.Echo strAttribute & " -- " & strItem
        Next
    Else
        Wscript.Echo strAttribute & " --  No value set"
        Err.Clear
    End If
Next
	

Lists all the attributes and values for an ADAM inetOrgPersonAccount named Syedabbas.


On Error Resume Next Set objUser = GetObject _ ("LDAP://localhost:389/cn=syedabbas,ou=Accounting,dc=fabrikam,dc=com") Set objUserProperties = GetObject("LDAP://localhost:389/schema/inetOrgPerson") For Each strAttribute in objUserProperties.MandatoryProperties strValues = objUser.GetEx(strAttribute) For Each strItem in strValues Wscript.Echo strAttribute & " -- " & strItem Next Next For Each strAttribute in objUserProperties.OptionalProperties strValues = objUser.GetEx(strAttribute) If Err = 0 Then For Each strItem in strValues Wscript.Echo strAttribute & " -- " & strItem Next Else Wscript.Echo strAttribute & " -- No value set" Err.Clear End If Next
List All ADAM inetOrgPerson Attributes and Values

List All ADAM OU Attributes and Values


Lists all the attributes and values for an ADAM OU named Accounting.
On Error Resume Next

Set objUser = _
    GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
Set objUserProperties = GetObject _
    ("LDAP://localhost:389/schema/organizationalUnit")

For Each strAttribute in objUserProperties.MandatoryProperties
    strValues = objUser.GetEx(strAttribute)
    For Each strItem in strValues
        Wscript.Echo strAttribute & " -- " & strItem
    Next
Next

For Each strAttribute in objUserProperties.OptionalProperties
    strValues = objUser.GetEx(strAttribute)
    If Err = 0 Then
        For Each strItem in strValues
            Wscript.Echo strAttribute & " -- " & strItem
        Next
    Else
        Wscript.Echo strAttribute & " --  No value set"
        Err.Clear
    End If
Next
	

List All ADAM OUs


Lists all the OUs in an ADAM domain.
On Error Resume Next

Set objDomain = GetObject("LDAP://localhost:389/dc=fabrikam,dc=com")
objDomain.Filter = Array("organizationalUnit")

For Each objOU in objDomain
    strNames = strNames & objOU.Name & vbcrlf
    ShowOUS objOU.AdsPath
Next

Sub ShowOUs(OUName)
    Set objNextOU = GetObject(OUname)
    objNextOU.Filter = Array("organizationalUnit")
    For Each objSubOU in objNextOU
        strNames = strNames & "     " & objSubOU.Name & vbcrlf
        ShowOUS objSubOU.AdsPath
    Next
End Sub

Wscript.Echo strNames
	

List All ADAM User Attributes and Values


Lists all the attributes and values for an ADAM user account named Kenmyer.
On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=kenmyer,ou=Accounting,dc=fabrikam,dc=com")
Set objUserProperties = GetObject("LDAP://localhost:389/schema/user")

For Each strAttribute in objUserProperties.MandatoryProperties
    strValues = objUser.GetEx(strAttribute)
    For Each strItem in strValues
        Wscript.Echo strAttribute & " -- " & strItem
    Next
Next

For Each strAttribute in objUserProperties.OptionalProperties
    strValues = objUser.GetEx(strAttribute)
    If Err = 0 Then
        For Each strItem in strValues
            Wscript.Echo strAttribute & " -- " & strItem
        Next
    Else
        Wscript.Echo strAttribute & " --  No value set"
        Err.Clear
    End If
Next
	

List the ADAM OU Schema


Lists all the mandatory and optional attributes of the ADAM organizationalUnit object.
On Error Resume Next

Set objUserProperties = GetObject("LDAP://localhost:389/schema/organizationalUnit")
WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objUserProperties.MandatoryProperties
    WScript.Echo strAttribute
Next

Wscript.Echo

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objUserProperties.OptionalProperties
    WScript.Echo strAttribute
Next
	

List the ADAM User Schema


Lists all the mandatory and optional attributes of the ADAM user object.
On Error Resume Next

Set objUserProperties = GetObject("LDAP://localhost:389/schema/user")
WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objUserProperties.MandatoryProperties
    WScript.Echo strAttribute
Next

Wscript.Echo

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objUserProperties.OptionalProperties
    WScript.Echo strAttribute
Next
	

List All the Users in an ADAM OU


Lists all the user accounts in an ADAM OU named Accounting.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Filter = Array("user")

For Each objUser in objOU
    Wscript.Echo objUser.Name
Next
	

List All the Members of an ADAM Group


Lists all the members of an ADAM group named Accountants.
On Error Resume Next

Set objGroup = GetObject _
    ("LDAP://localhost:389/cn=Accountants,ou=Accounting,dc=fabrikam,dc=com")

For Each objUser in objGroup.Members
    Wscript.Echo objUser.Name
Next
	

List All the Accounts in an ADAM OU


Lists all the accounts (of any type) in an ADAM OU named Accounting.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")

For Each objUser in objOU
    Wscript.Echo objUser.Name
Next
	

List All the Groups in an ADAM OU


Lists all the group accounts in an ADAM OU named Accounting.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Filter = Array("group")

For Each objUser in objOU
    Wscript.Echo objUser.Name
Next
	

List All the inetOrgPersons in an ADAM OU


Lists all the inetOrgPerson accounts in an ADAM OU named Accounting.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Filter = Array("inetOrgPerson")

For Each objUser in objOU
    Wscript.Echo objUser.Name
Next
	

List the ADAM Container Schema


Lists all the mandatory and optional attributes of the ADAM container object.
On Error Resume Next

Set objUserProperties = GetObject("LDAP://localhost:389/schema/container")
WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objUserProperties.MandatoryProperties
    WScript.Echo strAttribute
Next

Wscript.Echo

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objUserProperties.OptionalProperties
    WScript.Echo strAttribute
Next
	

List the ADAM inetOrgPerson Schema


Lists all the mandatory and optional attributes of the ADAM inetOrgPerson object.
On Error Resume Next

Set objUserProperties = GetObject("LDAP://localhost:389/schema/inetOrgPerson")
WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objUserProperties.MandatoryProperties
    WScript.Echo strAttribute
Next

Wscript.Echo

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objUserProperties.OptionalProperties
    WScript.Echo strAttribute
Next
	

List the ADAM Group Schema


Lists all the mandatory and optional attributes of the ADAM group object.
On Error Resume Next

Set objUserProperties = GetObject("LDAP://localhost:389/schema/group")
WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objUserProperties.MandatoryProperties
    WScript.Echo strAttribute
Next

Wscript.Echo

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objUserProperties.OptionalProperties
    WScript.Echo strAttribute
Next
	

List the ADAM Contact Schema


Lists all the mandatory and optional attributes of the ADAM contact object.
On Error Resume Next

Set objUserProperties = GetObject("LDAP://localhost:389/schema/contact")
WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objUserProperties.MandatoryProperties
    WScript.Echo strAttribute
Next

Wscript.Echo

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objUserProperties.OptionalProperties
    WScript.Echo strAttribute
Next
	

List the Groups an ADAM User Belongs to


Lists all the groups that the ADAM user Kenmyer is a member of.
On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=kenmyer,ou=Accounting,dc=fabrikam,dc=com")
arrMembersOf = objUser.GetEx("memberOf")

For Each strMemberOf in arrMembersOf
  WScript.Echo strMemberOf
Next
	

Verify that ADAM is Installed


Verifies that ADAM is installed on a computer.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service where Name Like '%ADAM_%'")

If colServices.Count = 0 Then
    Wscript.Echo "ADAM is not installed."
Else
    For Each objService in colServices
        Wscript.Echo objService.Name & " -- " & objService.State
    Next
End If