Platform SDK: Active Directory, ADSI, and Directory Services |
The IADsMembers::get__NewEnum method gets a dependent enumerator object that implements IEnumVARIANT for this ADSI collection object. Note that there are two underscore characters in the function name (get__NewEnum).
HRESULT IADsMembers::get__NewEnum( IUnknown ** ppEnumerator );
This method supports the standard return values, including S_OK. For other return values, see ADSI Error Codes.
The following Visual Basic code snippet enumerates members of collection.
Dim grp As IADsGroup Set grp = GetObject("WinNT://Microsoft/SaleGroup") For Each member in Grp MsgBox member.Name Next member
The following C++ code snippet enumerates members of any collection object that supports the IADsMembers interface.
HRESULT EnumMembers(IADsMembers *pMembers) { IUnknown *pUnk; HRESULT hr; hr = pMembers->get__NewEnum(&pUnk); if (FAILED(hr)) return hr; pMembers->Release(); IEnumVARIANT *pEnum; hr = pUnk->QueryInterface(IID_IEnumVARIANT,(void**)&pEnum); if (FAILED(hr)) return hr; pUnk->Release(); // Now Enumerate BSTR bstr; VARIANT var; IADs *pADs; ULONG lFetch; IDispatch *pDisp; VariantInit(&var); hr = pEnum->Next(1, &var, &lFetch); while(hr == S_OK) { if (lFetch == 1) { pDisp = V_DISPATCH(&var); pDisp->QueryInterface(IID_IADs, (void**)&pADs); pADs->get_Name(&bstr); printf("MEMBERS: %S\n",bstr); SysFreeString(bstr); pADs->Release(); } VariantClear(&var); pDisp=NULL; hr = pEnum->Next(1, &var, &lFetch); }; hr = pEnum->Release(); return S_OK; }
Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
Windows 95/98: Requires Windows 95 or later (with DSClient).
Header: Declared in Iads.h.
IEnumVARIANT, ADSI Error Codes, IADsMembers, IADsMembers Property Methods