Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Der folgende Code fügt der IAS-Richtliniensammlung eine neue Richtlinie hinzu. Die Variable pClientsCollection verweist auf eine ISdoCollection-Schnittstelle für die Auflistung. Informationen zum Abrufen des Auflistungsobjekts finden Sie unter Abrufen einer Sammlung .
HRESULT hr;
_bstr_t bstrClientName = L"Test Client";
VARIANT_BOOL vbNameUnique = VARIANT_FALSE;
//
// Check if the new client's name is unique
//
hr = pClientsCollection->IsNameUnique(bstrClientName, &vbNameUnique);
if (FAILED(hr))
{
return hr;
}
if (VARIANT_FALSE == vbNameUnique)
{
//
// The name is not unique. Handle the error
//
return E_FAIL;
}
//
// Name is unique. Add the client.
//
CComPtr<IDispatch> pClientDispatch;
pClientDispatch.p = NULL;
hr = pClientsCollection->Add(bstrClientName, &pClientDispatch);
if (FAILED(hr))
{
return hr;
}
CComPtr<ISdo> pClientSDO;
hr = pClientDispatch->QueryInterface(
__uuidof(ISdo),
(void**) &pClientSDO
);
if (FAILED(hr))
{
return hr;
}
//
// Set the address for the client
//
_variant_t vtClientAddress = L"127.0.0.1";
hr = pClientSDO->PutProperty(PROPERTY_CLIENT_ADDRESS, &vtClientAddress);
if (FAILED(hr))
{
return hr;
}
//
// Set the shared secret for the client
//
_variant_t vtClientSecret = L">@U#'6cc='5Ly9O5QKEj2RTJr*fM";
hr = pClientSDO->PutProperty(PROPERTY_CLIENT_SHARED_SECRET, &vtClientSecret);
if (FAILED(hr))
{
return hr;
}
//
// Apply the changes
//
hr = pClientSDO->Apply();
if (FAILED(hr))
{
return hr;
}
//
// Refresh the service using a ISdoServiceControl interface retrieved
// in the code sample "Retrieve a Service SDO"
//
hr = pSdoServiceControl->ResetService();
if (FAILED(hr))
{
//
// If IAS is not installed or is not running then ignore the error
//
}
Zugehörige Themen