Tworzenie tożsamości równorzędnej
Interfejs API programu Identity Manager umożliwia utworzenie tożsamości równorzędnej do użycia w sieci równorzędnej.
Podczas tworzenia tożsamości równorzędnej można podać następujące opcjonalne informacje:
- klasyfikator
- Przyjazna nazwa
- Dostawca usług kryptograficznych
Notatka
Jeśli to możliwe, ponownie użyj tożsamości rówieśnika.
Przykład Tworzenia i Usuwania Tożsamości Równorzędnej
Poniższy fragment kodu pokazuje, jak utworzyć i usunąć tożsamość równorzędną, używając klasyfikatora i przyjaznej nazwy.
#define UNICODE
#include <p2p.h>
#include <stdio.h>
#pragma comment(lib, "p2p.lib")
//-----------------------------------------------------------------------------
// Function: CreateIdentity
//
// Purpose: Creates a new Identity.
//
// Returns: HRESULT
//
HRESULT CreateIdentity(PWSTR pwzFriendlyName)
{
HRESULT hr = S_OK;
PWSTR pwzClassifier = L"GroupMember";
PWSTR pwzIdentity = NULL;
hr = PeerIdentityCreate(pwzClassifier, pwzFriendlyName, 0, &pwzIdentity);
if (FAILED(hr))
{
printf("Failed to create identity.");
}
else
{
printf("Identity: %s", pwzFriendlyName);
}
PeerFreeData(pwzIdentity);
return hr;
}
//-----------------------------------------------------------------------------
// Function: DeleteIdentity
//
// Purpose: Delete the identity created by CreateIdentity
//
// Returns: HRESULT
//
HRESULT DeleteIdentity()
{
HRESULT hr = S_OK;
if (g_pwzIdentity)
{
hr = PeerIdentityDelete(g_pwzIdentity);
g_pwzIdentity = NULL;
}
return hr;
}