You are here:
ActiveXperts.com > ActiveXperts Network Monitor > WindowsManagement > Scripts > Other Directory Services > ADAM > Retrieving Information
Quicklinks
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 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
Lists all the attributes and values for the ADAM container named Users.
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
List All ADAM inetOrgPerson Attributes and Values
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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