大网数据广告活动
Web服务器与PHP

Authentication with Multiple Known Headers

· 52CE 我爱测

The HTTP_MULTIPLE_KNOWN_HEADERS structure enables server applications to send multiple authentication challenges to the client.

The HTTP_MULTIPLE_KNOWN_HEADERS structure enables server applications to send multiple authentication challenges to the client. Applications can challenge the client with a single authentication scheme by supplying the HttpHeaderWwwAuthenticate enumeration type in the KnownHeaders member of the HTTP_RESPONSE_HEADERS structure contained in HTTP_RESPONSE. However, when the server challenges with multiple authentication schemes, the application uses the HTTP_MULTIPLE_KNOWN_HEADERS structure to provide the authentication types.

When the HTTP_RESPONSE_INFO_FLAGS_PRESERVE_ORDER flag is present, HTTP sends the authentication headers in the specified order. If the flag is not present, HTTP orders the authentication schemes from strongest to weakest as follows:

  1. Negotiate
  2. NTLM
  3. Digest
  4. Basic

If the authentication scheme is not one of these schemes, the application must specify the HTTP_RESPONSE_INFO_FLAGS_PRESERVE_ORDER flag.

The KnownHeader member of HTTP_MULTIPLE_KNOWN_HEADERS points to an array of HTTP_KNOWN_HEADER structures. The pRawValue member of the HTTP_KNOWN_HEADER structure must point to a string that specifies the scheme name. HTTP parses the string to determine the scheme and performs one of the following actions:

  • If the string contains an unknown authentication type, or if the authentication type is not enabled on the configuration group (either the URL group or server session) associated with the request, the HTTP Server API appends the string in pRawValue to the WWW-Authenticate header. For example, if the application specifies an unsupported authentication scheme, and pRawValue contains the string "CustomAuthString", the following text is appended to the authentication header:

    WWW-Authenticate: CustomAuthSchemeCRLF

    If the application does not have Basic authentication enabled, and pRawValue contains the string "Basic realm="BasicRealm"", the authentication header contains the following text:

    WWW-Authenticate: Basic realm="BasicRealm"

  • If the string contains a known authentication type and is present on the configuration group (either the URL group or the server session) associated with the request, the HTTP Server API generates the WWW-Authenticate header. For example if the string specified in pRawValue is "Digest", and Digest is enabled on the server session, the HTTP Server API appends the following text to the authentication header:

    WWW-Authenticate: Digest realm="testrealm@host.com"

If the scheme in the pRawValue member of HTTP_KNOWN_HEADER is Negotiate or NTLM, the authentication scheme name is sufficient. If the specified scheme is Basic, the realm name is appended to the scheme name; the application doesn't need to supply the realm name in pRawValue. If the specified scheme is Digest, HTTP calls AcceptSecurityContext to generate the challenge that is appended to the scheme name. The parameters for Basic (realm) and Digest (realm and domain name) scheme are obtained from the corresponding configuration group authentication information.

When the application sends multiple authentication challenges to the client in Unknown request headers, the HTTP Server API sends these to the client without intervention. However this usage is not recommended.

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。