Platform SDK: Active Directory, ADSI, and Directory Services |
The property methods of the IADsContainer interface get or set the properties described in the following table. For a general discussion of property methods, see Interface Property Methods.
Property | Description |
---|---|
Count
[Visual Basic] [C++] |
The number of items in the container. When Filter (see the next entry) is set, count returns only the number of filtered items. |
Filter
[Visual Basic] [C++] |
The filter used to select object classes in a given enumeration. This is a variant array, each element of which is the name of a schema class. If Filter is not set or set to empty, all objects of all classes are retrieved by the enumerator. |
Hints
[Visual Basic] [C++] |
A variant array of BSTR strings. Each element identifies the name of a property found in the schema definition. The vHints parameter allows the client to indicate which attributes to load for each enumerated object. Such information may be used to optimize network access. The exact implementation, however, is provider-specific. |
The enumeration processes beneath IADsContainer::get__NewEnum and IADsContainer::get_Count are carried out against the contained objects in the cache. When a container contains a large number of objects, the performance may be an issue. To enhance the performance, you should turn off the cache, set up an appropriate page size, and use the IDirectorySearch interface. For this reasons, the get_Count property is not supported in the LDAP provider supplied by Microsoft®.
The following Visual Basic code snippet shows how the property methods of IADsContainer can be used.
Dim cont as IADsContainer Dim usr as IADsUser Set cont = GetObject("LDAP://OU=Sales, DC=Fabrikam, DC=COM") cont.Hints = Array("adminDescription") ' Load only this attribute (optional) Debug.Print cont.Get("adminDescription") 'We want only users. cont.Filter = Array("user") For Each usr In cont Debug.Print usr.Name Next
The following C++ code snippet shows how the property methods of IADsContainer can be used. For brevity, error checking is omitted.
IADsContainer *pCont; IADs *pChild; IADs *pADs; HRESULT hr = ADsGetObject(L"LDAP://OU=Sales,DC=Fabrikam,DC=COM", IID_IADsContainer, (void**)&pCont); LPWSTR pszArray[] = { L"adminDescription" }; DWORD dwNumber = sizeof(pszArray)/sizeof(LPWSTR); hr = ADsBuildVarArrayStr( pszArray, dwNumber, &var); hr = pCont->put_Hints( var ); VariantClear(&var); hr = pCont->QueryInterface(IID_IADs, (void**)pADs); hr = pADs->Get(L"adminDescription", var); LPWSTR pszUsers = {L"user"}; dwNumber = sizeof(pszUsers)/sizeof(LPWSTR); hr = ADsBuildVarArrayStr(pszUsers, dwNumber, &var); hr = pCont->put_Filter( var ); VariantClear(&var); // Enumerate user objects in the container IEnumVARIANT *pEnum = NULL; hr = ADsBuildEnumerator(pCont, &pEnum); pCont->Release(); // no longer needed once we have users. ULONG lFetch; VariantClear(&var); while (SUCCEEDED(ADsEnumerateNext(pEnum, 1, &var, &lFetch)) && lFetch==1) { hr = V_DISPATCH(&var)->QueryInterface(IID_IADs, (void**)&pChild) if(SUCCEEDED(hr)) { BSTR bstrName; pChild->get_Name(&bstrName); printf(" %S\n", bstrName); SysFreeString(bstrName); pChild->Release(); } VariantClear(&var); }