Auflisten von Objekten in einer Auflistung
Hinweis
Der Internetauthentifizierungsdienst (Internet Authentication Service, IAS) wurde ab Windows Server 2008 in Netzwerkrichtlinienserver (Network Policy Server, NPS) umbenannt. Der Inhalt dieses Themas gilt sowohl für IAS als auch für NPS. Im gesamten Text wird NPS verwendet, um auf alle Versionen des Diensts zu verweisen, einschließlich der Versionen, die ursprünglich als IAS bezeichnet wurden.
Der folgende Code listet die Protokolle in der NPS-Protokollauflistung auf.
HRESULT hr;
//
// Retrieve the protocols collection object
//
_variant_t vtIASProtocolsCollection;
hr = pSdo->GetProperty(
PROPERTY_IAS_PROTOCOLS_COLLECTION,
&vtIASProtocolsCollection
);
if (FAILED(hr))
{
return hr;
}
//
// Retrieve the ISdoCollection interface
// for the object.
//
CComPtr<ISdoCollection> pIASProtocolsCollection;
hr = vtIASProtocolsCollection.pdispVal->QueryInterface(
__uuidof(ISdoCollection),
(void **) &pIASProtocolsCollection
);
if (FAILED(hr))
{
return hr;
}
//
// Retrieve the enumeration interface, IEnumVARIANT
//
CComPtr<IUnknown> pUnknownProtocol;
hr = pIASProtocolsCollection->get__NewEnum(&pUnknownProtocol);
if (FAILED(hr))
{
return hr;
}
CComPtr<IEnumVARIANT> pEnumProtocols;
hr = pUnknownProtocol->QueryInterface(
__uuidof(IEnumVARIANT),
(void **) &pEnumProtocols
);
if (FAILED(hr))
{
return hr;
}
//
// Retrieve the first protocol from the collection
//
DWORD dwRetrieved = 1;
_variant_t vtProtocol;
hr = pEnumProtocols->Next(1, &vtProtocol, &dwRetrieved);
if (FAILED(hr))
{
return hr;
}
while (hr != S_FALSE) {
//
// Retrieve the name of the protocol
//
CComPtr<ISdo> pLocalSdo;
hr = vtProtocol.pdispVal->QueryInterface(
__uuidof(ISdo),
(void**)&pLocalSdo
);
if (FAILED(hr))
{
return hr;
}
_variant_t vtName;
hr = pLocalSdo->GetProperty(PROPERTY_SDO_NAME, &vtName);
if (FAILED(hr))
{
return hr;
}
vtProtocol.Clear();
vtName.Clear();
//
// Retrieve the next protocol from the collection
//
dwRetrieved = 1;
hr = pEnumProtocols->Next(1, &vtProtocol, &dwRetrieved);
if (FAILED(hr))
{
return hr;
}
}
Bemerkungen
Die Variablen vtName und vtProtocol sind vom Typ _variant_t. Ein _variant_t -Objekt kapselt oder umschließt den VARIANT-Datentyp . Die -Klasse verwaltet die Ressourcenzuordnung und -zuordnung und führt ggf. Funktionsaufrufe an VariantInit und VariantClear aus.
Zugehörige Themen