取得預設摘要認證
用戶端和伺服器都必須取得 認證 ,才能建立訊息交換 的安全性內容 。 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,以指出用戶端將使用函式所傳回的認證控制碼。
如需示範為登入使用者以外的安全性主體取得認證的範例,請參閱 取得替代認證。