# 安全标识符

**安全标识符（security identifier，SID）** 是 Windows 用来标识安全主体的一种变长值，所谓安全主体，是指任何可被授予或拒绝资源访问权限的账户或组。每个账户的 SID 都由 Windows 域控制器之类的授权机构签发，并存放在安全数据库中。<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup> 操作系统的访问检查所匹配的是 SID，而不是账户名：安全系统在个人的 SID 与 ACL 中的 SID 之间查找匹配项，完全不看账户名。<sup>[2](https://devblogs.microsoft.com/oldnewthing/20240610-00/?p=109872)</sup>

| 关键事实 | 说明 |
|---|---|
| 字符串语法 | S-R-X-Y1-Y2-…-Yn：修订版 R、标识符授权机构 X、子授权机构 Y；对于域账户和域组 SID，最后一个子授权机构是相对标识符（RID），用以在该域内区分各主体<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup> |
| 二进制布局 | 修订版恒为 1，一个相对标识符计数，一个标明签发方的标识符授权机构，以及零个或多个 32 位相对标识符<sup>[3](https://nostarch.com/download/WindowsSecurityInternals_Chapter5.pdf)</sup> |
| 实例 | S-1-5-32-544：修订版 1、授权机构 5（NT 授权机构）、域 32（Builtin）、RID 544（Administrators）<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup> |
| SID 的存放位置 | 安全描述符中（所有者和主组）、访问控制项中（受托者），以及访问令牌中（用户及其所属各组）<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup> |
| 唯一性 | 只要签发得当，SID 在其作用域（域或本地）内唯一，且账户删除后不会被重新使用<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup> |
| 2025 年强化措施 | 2025 年 8 月 29 日及之后的更新强制实施 SID 检查，因此在 Windows 11 24H2/25H2 和 Windows Server 2025 上，SID 重复的设备之间 Kerberos 与 NTLM 认证会失败<sup>[4](https://support.microsoft.com/en-us/topic/kerberos-and-ntlm-authentication-failures-due-to-duplicate-sids-76f7394d-c460-4882-9ed1-d27e0960f949)</sup> |

## SID 的结构

字符串形式遵循 S-R-X-Y1-Y2-…-Yn 的模式。修订版字段（R）表示 SID 结构版本。标识符授权机构（X）标识签发机构：值 1 为全球授权机构（World Authority），用于通用的 Everyone 组；值 5 为 NT 授权机构（NT Authority），用于 Windows 账户和组。对于域账户和域组 SID，各子授权机构（Y1 至 Yn）共同标识该域，最后一个子授权机构即 RID，用以在该域内把该主体与其他账户和组区分开；任何域中都不会有两个账户或组共用同一个 RID。<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup>

在二进制形式下，SID 由四个部分组成：恒设为 1 的修订版值、一个相对标识符计数、一个标识签发方的安全授权机构值，以及零个或多个代表用户或组的 32 位相对标识符。<sup>[3](https://nostarch.com/download/WindowsSecurityInternals_Chapter5.pdf)</sup> 应用程序可以用 AllocateAndInitializeSid 函数，将一个标识符授权机构值与最多八个子授权机构值组合起来，构造一个众所周知的安全标识符；这一 API 限制只针对该辅助函数，未必适用于磁盘上的格式。<sup>[5](https://learn.microsoft.com/en-us/windows/win32/secauthz/well-known-sids)</sup>

## 在 Windows 访问控制中的作用

SID 出现在三个地方，三者共同决定访问是否放行。附着在对象上的安全描述符携带其所有者和主组的 SID，其自主访问控制列表（DACL）则为每个访问控制项（ACE）携带一个 SID。进程携带的访问令牌列出用户的 SID 及该用户所属每一个组的 SID。访问检查就是把这两者作比对。<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup>

匹配算法不看名字。当有人试图访问某个资源时，安全系统会在该人的 SID 与 ACL 中的 SID 之间查找匹配项；一条 ACE 完全可以写成“允许 S-1-5-21-2127521184-1604012920-1887927527-72713 拥有只读访问权限”，而系统既不知道也不关心这个 SID 代表谁。<sup>[2](https://devblogs.microsoft.com/oldnewthing/20240610-00/?p=109872)</sup> 系统按顺序检查 DACL 中的各条 ACE：如果某条 ACE 的 SID 与令牌中的某个 SID 匹配，且其访问位与剩余所需的访问权限相匹配，则拒绝类型的 ACE 立即返回 ACCESS_DENIED，允许类型的 ACE 则授予指定的访问权限；如果走到 DACL 末尾仍有未获授予的所需访问权限，则拒绝访问。<sup>[6](https://empyreal96.github.io/nt-info-depot/CS490_Windows_Internals/15_security.pdf)</sup>

实践中还有两处细节值得注意。自 [Windows Vista](https://www.edgepedia.org/zh/windows-vista) 和 [Windows Server 2008](https://www.edgepedia.org/zh/windows-server-2008) 起，当存在限制性 SID（restricting SIDs）时，Windows 会执行两次访问检查，一次常规检查、一次针对限制性 SID 的检查，两者都必须通过。<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup> 同样自 Vista 起，大多数操作系统文件归 TrustedInstaller SID 所有，因此管理员和 LocalSystem 进程无法自动替换操作系统文件。<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup> 应用程序可以通过构造众所周知的安全标识符，并用 EqualSid 将其与用户访问令牌中的组 SID 作比较，来检验组成员资格。<sup>[5](https://learn.microsoft.com/en-us/windows/win32/secauthz/well-known-sids)</sup>

## 众所周知的安全标识符与内置 SID

众所周知的安全标识符（well-known SID）用于标识通用组和内置别名，其取值固定且与机器无关，因此在任何一个 Windows 安装实例上，同一个 SID 含义相同。<sup>[5](https://learn.microsoft.com/en-us/windows/win32/secauthz/well-known-sids)</sup> 最典型的例子是 S-1-5-32-544，即内置的 Administrators 本地组（API 常量 DOMAIN_ALIAS_RID_ADMINS，值 0x00000220）：修订版 1、标识符授权机构 5（NT 授权机构）、域标识符 32（Builtin）、RID 544（Administrators）。<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup><sup> • </sup><sup>[5](https://learn.microsoft.com/en-us/windows/win32/secauthz/well-known-sids)</sup> 由于这些值是常量，授予 Administrators 或 Everyone 访问权限的 ACL 在任何机器上都使用同一个众所周知的安全标识符。

## 域、RID 与机器 SID

对于域账户，主体的 SID 由域的 SID 与该账户的 RID 拼接而成。只要签发得当，SID 在其作用域（域或本地）内就是唯一的，且账户删除后不会被重新使用。<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup> 当用户对象在域之间移动时，系统会生成一个新的 SID 存入 objectSID 属性，同时把原来的值复制到 SIDHistory 属性中，该属性可以保存多个值。<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup> 登录时，域身份验证会返回用户当前的 SID、SIDHistory 中的旧 SID 以及所有组 SID；它们全都会进入访问令牌，可以允许或拒绝资源访问。正因如此，在域之间移动用户无需修改资源 ACL：某个 ACL 可能只保存了旧 SID，但旧 SID 仍在令牌之中。<sup>[1](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)</sup>

机器也是安全主体，其 SID 已成为一项强化重点。在 2025 年 8 月 26 日及之后发布的更新中，微软引入了持久化的机器账户 SID，在系统重启后保持一致，以维持稳定的机器标识；机器 ID 现在同时包含每次启动和跨启动两部分，因此跨启动机器 ID 相同的克隆主机可能会认证失败。<sup>[7](https://support.microsoft.com/en-us/servicing/os/windows/2025/09/strengthening-administrator-protection-and-kerberos-authentication)</sup>

## 与 Unix UID 及云标识符的比较

Cygwin 的文档认为，SID 大体上相当于 POSIX 用户 ID（UID）和组 ID（GID），但更复杂，因为它们在多台机器或域之间都是唯一的。<sup>[8](https://cygwin.com/cygwin-ug-net/ntsec.html)</sup> 在 Windows 与 Unix 交汇之处，转换是显式的：Samba 的 winbindd 实现了 IDMapping（IDMap），把 S-1-5-21-4262773471-1330489575-488031063-2616 之类的 Windows SID 转换为 Unix UID 或 GID，并可反向转换。Samba 文档建议在文件服务器上使用 winbind，在 Linux 工作站上使用 SSSD。<sup>[9](https://samba.tranquil.it/doc/en/samba_fundamentals-about_winbindd.html)</sup>

在微软的云目录中，Entra ID 的主体同样以 S-1-12-1 形式的 SID 出现。据一份专业报告，Windows 内部版本 27881 引入了一项名为 AADSidToNameV2Support 的内部功能，将 SID 到名称的查找从用户扩展到 Entra 组和角色，从而能解析此前无法读取的 S-1-12-1 SID；无法识别的 Entra SID 会通过向端点 https://login.microsoftonline.com/ /sidtoname 发送经设备 Entra 证书签名的已认证请求来解析，结果缓存在 HKLM\SOFTWARE\Microsoft\IdentityStore\Cache\<SID>\IdentityCache 下以供离线使用。<sup>[10](https://patchmypc.com/blog/windows-finally-translates-entra-group-and-role-sids-to-real-names/)</sup>

## 管理与安全实践

**双向查找。** 管理员在 [PowerShell](https://www.edgepedia.org/zh/powershell) 中既可以通过 .NET Framework 类，也可以拿 SID 用 LDAP 查询检索用户名，从而把 SID 转换为用户名。<sup>[11](https://devblogs.microsoft.com/scripting/use-powershell-to-translate-a-users-sid-to-an-active-directory-account-name/)</sup> 转换失败是有正当理由的：由于安全系统从不需要名称，一条 ACE 可能引用一个底层账户已不存在的 SID，此时 SID 到名称的转换不会返回任何有用的结果。<sup>[2](https://devblogs.microsoft.com/oldnewthing/20240610-00/?p=109872)</sup>

**重复 SID 与克隆。** 重复 SID 出现在未运行 Sysprep 就克隆或复制 Windows 安装的情况下，这种做法不受支持。自 2025 年 8 月 29 日及之后发布的更新起，微软引入了更严格的安全防护措施，要求对 SID 进行验证，因此在共用同一 SID 的设备上认证不再成功；此类失败尝试会在系统事件日志中显示为 lsasrv.dll 事件 ID 6167。<sup>[4](https://support.microsoft.com/en-us/topic/kerberos-and-ntlm-authentication-failures-due-to-duplicate-sids-76f7394d-c460-4882-9ed1-d27e0960f949)</sup> 克隆设备上事件 6167 的补救办法，是用系统准备工具（Sysprep）对映像做通用化处理。<sup>[7](https://support.microsoft.com/en-us/servicing/os/windows/2025/09/strengthening-administrator-protection-and-kerberos-authentication)</sup> 永久解决则需要用受支持的克隆方法重建受影响的设备；商业客户可通过微软支持获取一项临时的专用[组策略](https://www.edgepedia.org/zh/group-policy)。<sup>[4](https://support.microsoft.com/en-us/topic/kerberos-and-ntlm-authentication-failures-due-to-duplicate-sids-76f7394d-c460-4882-9ed1-d27e0960f949)</sup>

**票证验证。** 2025 年的强化还堵住了一条欺骗路径：通过将机器账户 SID 与 Kerberos 票证中的 SID 进行校验，LSASS（本地安全机构子系统服务）能够检测并拒绝不匹配的票证，从而加强用户账户控制（UAC）防护。<sup>[7](https://support.microsoft.com/en-us/servicing/os/windows/2025/09/strengthening-administrator-protection-and-kerberos-authentication)</sup> 2025 年 8 月及之后发布的 Windows 更新会检测并阻止回环式的绕过行为，Windows 现在还会跨启动持久保存部分机器 ID。<sup>[12](https://techcommunity.microsoft.com/blog/windows-itpro-blog/hardening-administrative-actions-what-it-pros-need-to-know/4503956)</sup>

## 近期进展

对管理员而言，实际变化在于：机器标识长期以来只是 SID 设计中一个不起眼的细节，如今却成了强制执行的项。三项更新界定了这一转变：可跨重启存续的持久化机器账户 SID；由每次启动和跨启动两部分组成的机器 ID 组件，使克隆主机可被检测出来；以及在 [Windows 11](https://www.edgepedia.org/zh/windows-11) 24H2、25H2 和 Windows Server 2025 上，SID 检查使共用重复 SID 的设备之间 Kerberos 和 NTLM 认证直接失败。<sup>[7](https://support.microsoft.com/en-us/servicing/os/windows/2025/09/strengthening-administrator-protection-and-kerberos-authentication)</sup><sup> • </sup><sup>[4](https://support.microsoft.com/en-us/topic/kerberos-and-ntlm-authentication-failures-due-to-duplicate-sids-76f7394d-c460-4882-9ed1-d27e0960f949)</sup> 在客户端一侧，SID 到名称的转换如今延伸到云目录，可解析此前显示为不透明数字的 Entra 组和角色 SID。<sup>[10](https://patchmypc.com/blog/windows-finally-translates-entra-group-and-role-sids-to-real-names/)</sup> 其运维后果很直接：映像在部署前必须用 Sysprep 做通用化处理，而系统日志中的事件 6167 就是某个克隆漏掉了这一步的信号。<sup>[7](https://support.microsoft.com/en-us/servicing/os/windows/2025/09/strengthening-administrator-protection-and-kerberos-authentication)</sup>

## References

1. [Security Identifiers, Microsoft Learn](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers)
2. [How do I get the name of a SID, and what does it mean when the conversion fails?, Raymond Chen, Microsoft DevBlogs](https://devblogs.microsoft.com/oldnewthing/20240610-00/?p=109872)
3. [Windows Security Internals, Chapter 5, No Starch Press](https://nostarch.com/download/WindowsSecurityInternals_Chapter5.pdf)
4. [Kerberos and NTLM authentication failures due to duplicate SIDs, Microsoft Support](https://support.microsoft.com/en-us/topic/kerberos-and-ntlm-authentication-failures-due-to-duplicate-sids-76f7394d-c460-4882-9ed1-d27e0960f949)
5. [Well-known SIDs, Win32 apps, Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/secauthz/well-known-sids)
6. [Unit OS7: Windows Security Components and Concepts, Windows Internals courseware](https://empyreal96.github.io/nt-info-depot/CS490_Windows_Internals/15_security.pdf)
7. [Strengthening administrator protection and Kerberos authentication, Microsoft Support](https://support.microsoft.com/en-us/servicing/os/windows/2025/09/strengthening-administrator-protection-and-kerberos-authentication)
8. [POSIX accounts, permission, and security, Cygwin User's Guide](https://cygwin.com/cygwin-ug-net/ntsec.html)
9. [About Winbindd and IDMapping, Samba-AD documentation](https://samba.tranquil.it/doc/en/samba_fundamentals-about_winbindd.html)
10. [Windows Can Now Translate Entra Group and Role SIDs to Names, Patch My PC blog](https://patchmypc.com/blog/windows-finally-translates-entra-group-and-role-sids-to-real-names/)
11. [Use PowerShell to Translate a User's SID to an Active Directory Account Name, Microsoft Scripting Blog](https://devblogs.microsoft.com/scripting/use-powershell-to-translate-a-users-sid-to-an-active-directory-account-name/)
12. [Hardening administrative actions: What IT pros need to know, Windows IT Pro Blog](https://techcommunity.microsoft.com/blog/windows-itpro-blog/hardening-administrative-actions-what-it-pros-need-to-know/4503956)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Databases and data systems › Database security, privacy, and law › Database access control and security management

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/security-identifier

English original: https://www.edgepedia.org/security-identifier
