Metodo ICcgDomainAuthCredentials::GetPasswordCredentials (ccgplugins.h)

Restituisce le credenziali per autenticare un contenitore non aggiunto a un dominio con Active Directory.

Sintassi

HRESULT GetPasswordCredentials(
  LPCWSTR pluginInput,
  LPWSTR  *domainName,
  LPWSTR  *username,
  LPWSTR  *password
);

Parametri

pluginInput

Stringa di input passata dal runtime del contenitore. L'implementazione client usa la stringa di input fornita per recuperare le credenziali di autenticazione, in genere da un provider di archiviazione sicuro, restituite nei parametri di output. La stringa di input viene fornita a Host Compute Services (HCS) in un file di specifica delle credenziali. Per altre informazioni, vedere la sezione Osservazioni .

domainName

Nome di dominio per le credenziali

username

Nome utente per le credenziali.

password

Password per le credenziali.

Valore restituito

Il valore restituito è HRESULT. Un valore di S_OK indica che la chiamata ha avuto esito positivo.

Commenti

L'API può essere chiamata simultaneamente. Pertanto, lo sviluppatore deve assicurarsi che l'implementazione sia thread-safe. Inoltre, l'oggetto COM verrà attivato out-of-process e deve essere registrato in modo appropriato.

L'implementatore deve aggiungere una chiave in "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CCG\COMClasses" per il CLSID COM. L'accesso in scrittura a "CCG\COMClasses" è limitato agli account SYSTEM e Administrator.

Di seguito è riportato un file di specifica delle credenziali di esempio. Per informazioni sulla fornitura di questo file a Docker, vedere Eseguire un contenitore con un account del servizio gestito del gruppo.

{
    "CmsPlugins": [
        "ActiveDirectory"
    ],
    "DomainJoinConfig": {
        "Sid": "S-1-5-21-3700119848-2853083131-2094573802",
        "MachineAccountName": "gmsa1",
        "Guid": "630a7dd3-2d3e-4471-ae91-1d9ea2556cd5",
        "DnsTreeName": "contoso.com",
        "DnsName": "contoso.com",
        "NetBiosName": "CONTOSO"
    },
    "ActiveDirectoryConfig": {
        "GroupManagedServiceAccounts": [
            {
                "Name": "gmsa1",
                "Scope": "contoso.com"
            },
            {
                "Name": "gmsa1",
                "Scope": "CONTOSO"
            }
        ],
        "HostAccountConfig": {
            "PortableCcgVersion": "1",
            "PluginGUID": "{CFCA0441-511D-4B2A-862E-20348A78760B}",
            "PluginInput": "contoso.com:gmsaccg:<password>"
        }
    }
}

Esempio

L'esempio seguente illustra una semplice implementazione di ICcgDomainAuthCredentials. Si noti che, a scopo illustrativo, questo esempio ottiene le credenziali semplicemente analizzando la stringa di input. Un'implementazione reale archivia le credenziali in un archivio dati sicuro e usa la stringa di input per individuare le informazioni sulle credenziali. Inoltre, le implementazioni standard del metodo COM sono state omesse da questo esempio per brevità.

// UUID generated by the developer
[uuid("cfca0441-511d-4b2a-862e-20348a78760b")] 
class CCGStubPlugin : public RuntimeClass<RuntimeClassFlags<RuntimeClassType::ClassicCom>, ICcgDomainAuthCredentials >
{
   public:
    CCGStubPlugin() {}

    ~CCGStubPlugin() {}

    IFACEMETHODIMP GetPasswordCredentials(
        _In_ LPCWSTR pluginInput,
        _Outptr_ LPWSTR *domainName,
        _Outptr_ LPWSTR *username,
        _Outptr_ LPWSTR *password)
    {
        std::wstring domainParsed, userParsed, passwordParsed; 
        try
        {
            if(domainName == NULL || username == NULL || password == NULL)
            {
                return STG_E_INVALIDPARAMETER;
            }
            *domainName = NULL;
            *username = NULL;
            *password = NULL;
            wstring pluginInputString(pluginInput);
            if (count(pluginInputString.begin(), pluginInputString.end(), ':') < 2)
            {
                return CO_E_NOT_SUPPORTED;
            }
            // Extract creds of this format Domain:Username:Password
            size_t sep1 = pluginInputString.find(L":");
            size_t sep2 = pluginInputString.find(L":", sep1 + 1);
            domainParsed = pluginInputString.substr(0, sep1);
            userParsed = pluginInputString.substr(sep1 + 1, sep2 - sep1 - 1);
            passwordParsed = pluginInputString.substr(sep2 + 1);
        }
        catch (...)
        {
            return EVENT_E_INTERNALERROR;
        }

        auto userCo = wil::make_cotaskmem_string_nothrow(userParsed.c_str());
        auto passwordCo = wil::make_cotaskmem_string_nothrow(passwordParsed.c_str());
        auto domainCo = wil::make_cotaskmem_string_nothrow(domainParsed.c_str());
        if (userCo == nullptr || passwordCo == nullptr || domainCo == nullptr)
        {
            return STG_E_INSUFFICIENTMEMORY;
        }

        *domainName = domainCo.release();
        *username = userCo.release();
        *password = passwordCo.release();
        return S_OK;
    }
};
CoCreatableClass(CCGStubPlugin);

Requisiti

Requisito Valore
Client minimo supportato Windows 10 Build 20348
Server minimo supportato Windows 10 Build 20348
Intestazione ccgplugins.h

Vedi anche

ICcgDomainAuthCredentials