获取默认摘要凭据

客户端和服务器必须先获取 凭据 ,然后才能为消息交换建立 安全上下文AcquireCredentialsHandle 函数的默认行为是为与当前登录会话关联的安全主体提供凭据。

以下示例演示用于获取默认凭据的服务器端调用。

SECURITY_STATUS SecStatus; 
TimeStamp tsLifetime; 
CredHandle hCred;
SecStatus = AcquireCredentialsHandle (
       NULL,                  // Default principal.
       WDIGEST_SP_NAME,       // Microsoft Digest SSP. 
       SECPKG_CRED_INBOUND,   // Server will use the credentials.
       NULL,                  // Use the current LOGON id.
       NULL,                  // Default credentials.
       NULL,                  // Not used with Digest SSP.
       NULL,                  // Not used with Digest SSP.
       &hCred,                // Receives the credential handle.
       &tsLifetime            // Receives the credential time limit.
);

默认凭据的客户端调用是相同的,只不过第三个参数必须指定SECPKG_CRED_OUTBOUND以指示客户端将使用函数返回的凭据句柄。

有关演示如何为登录用户以外的安全主体获取凭据的示例,请参阅 获取备用凭据