Directory Services


The available properties of an ADSI Domain object vary depending on what namespace the object resides in. The following code examples can be used to determine what properties a given domain supports by looking at the Domain object's schema class object. A schema class object contains definitions of all the methods and properties supported by an object under a particular namespace provider. The ADsPath to an object's schema class object is stored in the Schema property. The Schema property is available on any ADSI object, not just domains.

A schema class object must be bound to retrieve useful data from it. The following code example shows can be used to bind to the schema class object for a particular domain.

Set myDomain = GetObject("WinNT://mydomain")
Set mySchemaClass = GetObject(myDomain.Schema)

When the schema class object is bound, its properties offer data about an object's supported properties, as well as its relation to other objects within its namespace. The schema class object has the following useful properties.

Property Description
Container A Boolean value, TRUE if the object is a container, FALSE if not.
Containment If the object is a container, the Containment property holds a list of all the types of ADSI objects this particular object can contain.
MandatoryProperties An array of all the properties that must be set for this object to be written to storage.
OptionalProperties An array of this object's optional properties.

The following code example displays the properties that are available in a given WinNT domain.

Dim myDomain
Dim mySchemaClass
Dim member

Set myDomain = GetObject("WinNT://MYDOMAIN")
Set mySchemaClass = GetObject(myDomain.Schema)

WScript.Echo "Properties for the " & myDomain.Name & " object"

If mySchemaClass.Container Then
	WScript.Echo myDomain.Name & " may contain the following objects:"
	For Each member In mySchemaClass.Containment
		WScript.Echo "	" & member
	WScript.Echo myDomain.Name & " is not a container."
End If

WScript.Echo "Mandatory properties:"
For Each member In mySchemaClass.MandatoryProperties
	WScript.Echo "	" & member

WScript.Echo "Optional properties:"
For Each member In mySchemaClass.OptionalProperties
	WScript.Echo "	" & member

The following code example produces output similar to the following.

Properties for the MYDOMAIN object

MYDOMAIN may contain the following objects:

Mandatory properties:

Optional properties:

Be aware that this code example may be used to retrieve the properties of any ADSI object, not just domains. Replace the path in the first GetObject call with the path to the object whose properties you are interested in.