Read an OU 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 read-an-ou-object ADSI class can be used in ActiveXperts Network Monitor to monitor your servers.
Example(s)
strContainer = "" strName = "EzAdOrganizationalUnit" On Error Resume Next '*********************************************** '* Connect to an object * '*********************************************** Set objRootDSE = GetObject("LDAP://rootDSE") If strContainer = "" Then arrNameExceptions = Array("Users","Computers","Builtin","System", _ "ForeignSecurityPrincipals","LostAndFound") For Each name in arrNameExceptions If lcase(strName) = lcase(name) Then strNameAttrib = "cn=" Exit For Else strNameAttrib = "ou=" End If Next Set objItem = GetObject("LDAP://" & strNameAttrib & strName & "," & _ objRootDSE.Get("defaultNamingContext")) Else Set objItem = GetObject("LDAP://ou=" & strName & "," & strContainer & "," & _ objRootDSE.Get("defaultNamingContext")) End If '*********************************************** '* End connect to an object * '*********************************************** WScript.Echo VbCrLf & "** General Properties Page**" WScript.Echo "** (Single-Valued Attributes) **" strname = objItem.Get("name") WScript.Echo "name: " & strname strdescription = objItem.Get("description") WScript.Echo "description: " & strdescription strstreetAddress = objItem.Get("streetAddress") WScript.Echo "streetAddress: " & strstreetAddress strpostOfficeBox = objItem.Get("postOfficeBox") WScript.Echo "postOfficeBox: " & strpostOfficeBox strl = objItem.Get("l") WScript.Echo "l: " & strl strst = objItem.Get("st") WScript.Echo "st: " & strst strpostalCode = objItem.Get("postalCode") WScript.Echo "postalCode: " & strpostalCode strc = objItem.Get("c") WScript.Echo "c: " & strc WScript.Echo VbCrLf & "** Managed By Properties Page**" WScript.Echo "** (Single-Valued Attributes) **" strmanagedBy = objItem.Get("managedBy") WScript.Echo "managedBy: " & strmanagedBy If strmanagedBy <> "" Then Set objItem1 = GetObject("LDAP://" & strManagedBy) WScript.Echo "physicalDeliveryOfficeName: " & _ objItem1.physicalDeliveryOfficeName WScript.Echo "streetAddress: " & _ objItem1.streetAddress WScript.Echo "l: " & _ objItem1.l WScript.Echo "c: " & _ objItem1.c WScript.Echo "telephoneNumber: " & _ objItem1.telephoneNumber WScript.Echo "facsimileTelephoneNumber: " & _ objItem1.facsimileTelephoneNumber End If WScript.Echo VbCrLf & "** Object Properties Page**" WScript.Echo "** (Single-Valued Attributes) **" strwhenCreated = objItem.Get("whenCreated") WScript.Echo "whenCreated: " & strwhenCreated strwhenChanged = objItem.Get("whenChanged") WScript.Echo "whenChanged: " & strwhenChanged objItem.GetInfoEx Array("canonicalName"), 0 WScript.Echo VbCrLf & "** Object Properties Page**" WScript.Echo "** (MultiValued Attributes) **" strcanonicalName = objItem.GetEx("canonicalName") WScript.Echo "canonicalName:" For Each Item in strcanonicalName WScript.Echo vbTab & Item Next WScript.Echo VbCrLf & "** Group Policy Properties Page**" WScript.Echo "** (Single-Valued Attributes) **" strgPLink = objItem.Get("gPLink") WScript.Echo "gPLink: " & strgPLink strgPOptions = objItem.Get("gPOptions") WScript.Echo "gPOptions: " & strgPOptions If strgPOptions = 1 Then WScript.Echo "Policy inheritance is blocked." ElseIf strgPOptions = 0 Then WScript.Echo "Policies are inherited." End If