Export (0) Print
Expand All

IADsContainer interface

The IADsContainer interface enables an ADSI container object to create, delete, and manage contained ADSI objects. Container objects represent hierarchical directory trees, such as in a file system, and to organize the directory hierarchy.

You can use the IADsContainer interface to either enumerate contained objects or manage their lifecycle. An example would be to recursively navigate a directory tree. By querying the IADsContainer interface on an ADSI object, you can determine if the object has any children. If the interface is not supported, the object is a leaf. Otherwise, it is a container. You can continue this process for the newly found container objects. To create, copy, or delete an object, send the request to the container object to perform the task.

Members

The IADsContainer interface inherits from the IDispatch interface. IADsContainer also has these types of members:

Methods

The IADsContainer interface has these methods.

MethodDescription
CopyHere

Copies an object to the container.

Create

Creates an object in the container.

Delete

Deletes an object in the container.

get__NewEnum

Retrieves an enumerator object for the container.

GetObject

Retrieves an interface for a directory object in the container.

MoveHere

Moves an object to the container.

 

Properties

The IADsContainer interface has these properties.

PropertyAccess typeDescription

Count

Read-only

Contains the number of directory objects in the container.

Filter

Read/write

Contains the filter on the schema classes to use for an enumeration.

Hints

Read/write

Contains the properties to retrieve for each object that is enumerated by the container.

 

Remarks

To determine if an object is a container, use the IADsClass.Container property of the object.

When you bind to a container object using its GUID (or SID), you can only perform specific operations on the container object. These operations include examination of the object attributes and enumeration of the object's immediate children. These operations are shown in the following code example.


Dim con As IADsContainer
Dim obj As IADs
Set con = GetObject("LDAP://svr01/<GUID=xxxx>")
con.Filter = Array("user")
For Each item In con
    debug.print item.Name " &  " of " & item.Class
Next

All other operations, that is, GetObject, Create, Delete, CopyHere, and MoveHere are not supported in the container's GUID representation. For example, the last line of the following code example will result in an error.


Dim con As IADsContainer
Dim obj As IADs
Set con = GetObject("LDAP://svr01/<GUID=xxxx>")
Set obj = con.GetObject("user", "CN=Jeff Smith")

Binding, using GUID (or SID), is intended for low overhead and, thus, fast binds, which are often used for object introspection.

To call these methods of the container bound with its GUID (or SID), rebind to the object using its distinguished name.


Dim conGUID, conDN As IADsContainer
Dim obj As IADs
Set conGUID = GetObject("LDAP://svr/<GUID=xxxx>")
Set conDN=GetObject("LDAP://svr/" & conGUID.Get("distinguishedName"))
Set obj = conDN.GetObject("user", "CN=Jeff Smith")

Windows Server 2003:  Binding to a container object with a GUID using the LDAP provider no longer returns a 'GUID ADsPath' for the child objects of the container, and rebinding is not required when attempting to access child objects with the GetObject, Create, Delete, CopyHere, and MoveHere methods.

For more information about object GUID representation, see IADs.GUID.

Examples

The following code example determines if an ADSI object is a container.


Dim obj As IADs
Dim cls As IADsClass
On Error GoTo Cleanup

Set obj = GetObject("WinNT://myComputer,computer")
Set cls = GetObject(obj.Schema)
If (cls.Container = TRUE) Then
    MsgBox "The object is a container."
Else
    MsgBox "The object is a leaf."
End If

Cleanup:
    If (Err.Number<>0) Then
        MsgBox("An error has occurred. " & Err.Number)
    End If
    Set obj = Nothing
    Set cls = Nothing

The following code example determines if an ADSI object is a container.


IADs *pADs = NULL;
IADsClass *pCls = NULL;
HRESULT hr = S_OK;
BSTR bstr;

hr = ADsGetObject(L"WinNT://myComputer,computer", IID_IADs, (void**)&pADs);
if(FAILED(hr)){return;}

pADs->get_Schema(&bstr);
hr = ADsGetObject(bstr, IID_IADsClass, (void**)&pCls);
pADs->Release();
SysFreeString(bstr);

if(FAILED(hr)){return;}

VARIANT_BOOL isContainer;
pCls->get_Container(&isContainer);

if(isContainer) 
    printf("Object is a container.\n");
else
    printf("Object is not a container.\n");

pCls->Release();


Requirements

Minimum supported client

Windows Vista [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2003 [desktop apps | Windows Store apps]

Header

Iads.h

DLL

Activeds.dll

IID

IID_IADsContainer is defined as 001677D0-FD16-11CE-ABC4-02608C9E7553

See also

IADsClass::get_Container
IADs::get_GUID
IADsNamespaces
Creating and Deleting Objects

 

 

Show:
© 2014 Microsoft