大网数据广告活动
网络与域名解析

Helper Tokens for BITS Transfer Jobs

· 52CE 我爱测

Helper Tokens for BITS Transfer Jobs

In Windows Vista, the Background Intelligent Transfer Service (BITS) service allows an application to associate a single security token to a BITS transfer job. The BITS transfer job then uses this token for authentication and for access to local and remote resources.

In Windows 7, the BITS service associates an additional token to a BITS transfer job. The BITS transfer job can be configured with an additional security token, which is an impersonation token created by an application calling the BITS COM API. This helper token model allows applications to simultaneously use two different security tokens to access local files, client-side certificates, remote files, and proxies. For example, a BITS transfer job is created that writes the downloaded data to a privileged local directory, and then it presents a low-rights domain identity to the HTTP server and proxy server.

An application, typically a Windows service, specifies a helper token by using the new interface IBitsTokenOptions. This interface is implemented by the BITS job object. The application calls IBackgroundCopyJob::QueryInterface to get the interface pointer. The application impersonates the helper identity and calls IBitsTokenOptions::SetHelperToken to pass the token to the BITS service. Then the application specifies the resources to which the token applies by passing a set of bit flags using IBitsTokenOptions::SetHelperTokenFlags. The application clears all the flags (using SetHelperTokenFlags again) to revert the behavior. The BITS service stores the bit flags and the token in the BITS transfer job.

When the owner of the BITS transfer jobs logs off, the BITS service discards any helper tokens that are associated with the transfer job. If the transfer is not complete, the BITS service places the job in an error state with the BG_E_TOKEN_REQUIRED error code and discards the helper token. The client application can refresh the token by calling IBitsTokenOptions::SetHelperToken and can then resume the BITS transfer job. Alternatively, the client application can clear the helper token flags using IBitsTokenOptions::SetHelperTokenFlags and then resume the transfer job without a helper token.

Similarly, when the owner of a terminal services session logs off, the BITS service must discard any helper tokens from that session and place the affected transfer jobs in an error state with the BG_E_TOKEN_REQUIRED error code.

The helper token model requires a change to BITS access control policy. Previous versions of BITS implemented access checks on every method call. Starting with Windows 7, the access check must be performed inside the IBackgroundCopyJob::QueryInterface call; otherwise, the helper token might not have access to the transfer job.

Note:
Older implementations effectively required that BITS users have administrator privileges in order to set helper tokens. Starting with Windows 10, version 1607, non-administrator BITS users can use IBitsTokenOptions::SetHelperToken to set non-administrator helper tokens on BITS jobs they own. This change enables non-administrator BITS users (such as background downloader services running under the NetworkService account) to set helper tokens.

Specifically, the implementation has been changed to allow users without administrator privileges to set helper tokens, as long as the following conditions are met:

Related topics

IBitsTokenOptions

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)

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

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