本文讨论了在使用 LDAP 客户端连接到基于 Windows Server 2025 的域控制器(DC)时访问机密属性的新要求。
症状
搜索或编辑 Active Directory 域服务(AD DS)对象时,你会注意到以下行为:
- 针对基于 Windows Server 2025 的 DC 运行轻型目录访问协议(LDAP)搜索请求时,生成的属性列表不包括机密属性。 但是,如果针对在 Windows Server 2022 或更早版本上运行的 DC 运行相同的 LDAP 查询,则可以在响应中获取完整的属性列表。
- 运行针对基于 Windows Server 2025 的 DC 添加或修改机密属性值的 LDAP 更新请求时,更新请求将失败并返回
INSUFF_ACCESS_RIGHTS错误消息。 如果针对在 Windows Server 2022 或更早版本上运行的 DC 运行相同的 LDAP 更新请求,则更新请求会成功。
示例 1:搜索结果省略机密属性
在此示例中,运行 Ldifde 查询尝试读取旧的本地管理员密码解决方案 (LAPS) 密码属性。 该查询类似于以下示例:
ldifde /s DC25 /d "CN=test-comp01,OU=New-Computers,DC=contoso,DC=com" /f test-comp01.txt /l ms-Mcs-AdmPwd,cn
客户端连接并导出对象的属性列表,并生成类似于以下示例的输出(如预期)。
Connecting to "dc25"
Logging in as current user using SSPI
Exporting directory to file test-comp01.txt
Searching for entries...
Writing out entries.
1 entries exported
注释
此示例文本是在 Windows 11、23H2 或早期版本的 Windows 上使用 LDAP 客户端创建的。
但是,查看导出的列表时,会找到“cn”属性,但找不到“ms-Mcs-AdmPwd”属性。
将查询定向到运行早期版本的 Windows 的 DC 时,生成的导出列表包括“cn”和“ms-Mcs-AdmPwd”。
下表汇总了不同客户端和服务器版本的行为。
| 客户 | 目标 DC | 返回的属性 |
|---|---|---|
| Windows 11,版本 24H2 | Windows Server 2025 | “cn”“ms-Mcs-AdmPwd” |
| Windows Server 2025 (成员服务器) | Windows Server 2025 | “cn”“ms-Mcs-AdmPwd” |
| 早于 Windows 11 版本 24H2 的 Windows 版本 | Windows Server 2025 | “cn” |
| 非 Windows作系统(例如基于 UNIX 的客户端) | Windows Server 2025 | “cn” |
| 早于 Windows 11 版本 24H2 的 Windows 版本 | Windows Server 2022 或更低版本 | “cn”“ms-Mcs-AdmPwd” |
| 非 Windows作系统(例如基于 UNIX 的客户端) | Windows Server 2022 或更低版本 | “cn”“ms-Mcs-AdmPwd” |
示例 2:机密属性的操作失败
在此示例中,将创建一个 LDIFDE 文件(命名为 Update.txt),用于修改机密属性的值。 为方便起见,此示例引用与前面的示例相同的旧 LAPS 密码。 (注意:我们不建议在实践中进行这种类型的更改)。 文件文本类似于以下示例:
dn: CN=test-comp01,OU=New-Computers,DC=contoso,DC=com
changetype: modify
replace: ms-Mcs-AdmPwd
ms-Mcs-AdmPwd: <PasswordText>
-
若要导入该文件,请打开 Windows 命令提示符窗口,然后运行以下命令:
ldifde /s dc25 -i /f .\update.txt
生成的输出类似于以下示例:
Connecting to "dc25"
Logging in as current user using SSPI
Importing directory from file ".\update.txt"
Loading entries.
Add error on entry starting on line 1: Insufficient Rights
The server side error is: 0x2098 Insufficient access rights to perform the operation.
The extended server error is:
00002098: SecErr: DSID-03151656, problem 4003 (INSUFF_ACCESS_RIGHTS), data 0
使用类似的方法尝试创建对象并为该对象的机密属性设置值时,生成的输出类似于以下示例:
Add error on entry starting on line 1: Insufficient Rights
The server side error is: 0x2098 Insufficient access rights to perform the operation.
The extended server error is:
00002098: SecErr: DSID-03153BAC, problem 4003 (INSUFF_ACCESS_RIGHTS), data 0
与前面的查询示例类似,作会成功或失败,具体取决于客户端和服务器版本。 下表汇总了这些交互。
| 客户 | 目标数据中心 | 作结果 |
|---|---|---|
| Windows 11,版本 24H2 | Windows Server 2025 | 成功 |
| Windows Server 2025 (成员服务器) | Windows Server 2025 | 成功 |
| 早于 Windows 11 版本 24H2 的 Windows 版本 | Windows Server 2025 | INSUFF_ACCESS_RIGHTS |
| 非 Windows作系统(例如基于 UNIX 的客户端) | Windows Server 2025 | INSUFF_ACCESS_RIGHTS |
| 早于 Windows 11 版本 24H2 的 Windows 版本 | Windows Server 2022 或更低版本 | 成功 |
| 非 Windows作系统(例如基于 UNIX 的客户端) | Windows Server 2022 或更低版本 | 成功 |
原因
由于 Windows Server 2025 DC 中的新功能,管理客户端必须建立与 AD DS 的加密连接,才能搜索、读取、添加或修改机密对象属性。 Windows Server 2025 中的新增功能介绍 说明了新特性:
- 改进了机密属性的安全性:DC 和 AD LDS 实例仅允许在连接加密的情况下,LDAP 执行涉及机密属性的添加、搜索和修改操作。
此行为不会影响在基于 Windows Server 2025 的成员服务器或基于 Windows 11 版本 24H2 的计算机上运行的 LDAP 客户端。 在这些作系统版本上,LDAP 客户端默认使用加密会话。
解决方法
若要解决此问题,请使用以下某种方法:
-
将 LDAP 客户端配置为使用 LDAP_OPT_ENCRYPT 会话选项(或更新到支持此选项的客户端)。 如果在 Windows 上使用 ldifde,请使用
/h开关(例如,运行ldifde /h /s dc25 -i /f .\update.txt)。 -
将 Windows Server 2025 或 Windows 11 24H2 或较新版本用作 LDAP 客户端。 默认情况下,这些作系统加密 LDAP 会话。 有关此功能的详细信息,请参阅 Windows Server 2025 中的新增功能。
-
如果无法使用上述任一方法,可以暂时禁用加密的会话要求。 有关详细信息,请参阅本文中的 dsHeuristics 如何影响加密会话要求和相关事件 。
重要
此方法不安全。 仅将其用作临时步骤。
详细信息
多个新的目录服务事件记录了此行为。 下表汇总了这些事件。
| 事件编号 | 客户端在未加密会话期间尝试的操作 | 用户错误(返回到客户端) |
|---|---|---|
| 3079 | 搜索一个或多个机密属性。 | None |
| 3080 | 为现有对象的机密属性设置值。 | INSUFF_ACCESS_RIGHTS |
| 3081 | 添加一个对象,该对象具有机密属性的值。 | INSUFF_ACCESS_RIGHTS |
事件 ID 3079 的详细信息
Log Name: Directory Service
Source: Microsoft-Windows-ActiveDirectory_DomainService
Event ID: 3079
Task Category: Security
Level: Warning
Keywords: Classic
User: contoso\admin
Computer: dc25.contoso.com
Description:
The directory blocked access to one or more confidential attributes on one or more LDAP search requests because one or more clients were using an unencrypted LDAP connection.
事件 ID 3080 的详细信息
Log Name: Directory Service
Source: Microsoft-Windows-ActiveDirectory_DomainService
Event ID: 3080
Task Category: Security
Level: Warning
User: contoso\admin
Computer: dc25.contoso.com
Description:
The directory blocked one or more LDAP modify requests including changes to one or more confidential attributes because one or more clients were using an unencrypted LDAP connection.
事件 ID 3081 的详细信息
Log Name: Directory Service
Source: Microsoft-Windows-ActiveDirectory_DomainService
Event ID: 3081
Task Category: Security
Level: Warning
User: contoso\admin
Computer: dc25.contoso.com
Description:
The directory blocked one or more LDAP add requests including changes to one or more confidential attributes because one or more clients were using an unencrypted LDAP connection.
dsHeuristics 如何影响加密的会话要求和相关事件
可以使用属性来修改加密会话的要求(例如,在测试方案中 dsHeuristics )。 例如,如果配置为 dsHeuristics 禁用用于搜索机密属性的加密会话要求,则使用 nonencrypted 会话的搜索会成功返回非机密结果和机密结果。 事件 ID 3079 不会显示在事件日志中。
该值 dsHeuristics 是一个字符串,其中单个字符或字符集反映参数值。 第 31 个字符表示值 DisableConfidentialAttributeEncryptionRequirements。 此值范围为 0 (强制实施所有加密会话要求)到 7 (所有加密会话要求均已禁用)。 例如, 0000000001000000000200000000037 是禁用 dsHeuristics 所有加密会话要求的值。 DisableConfidentialAttributeEncryptionRequirements 是一个三位值。 下表介绍了这些值如何与加密会话要求相关联。
| 受影响的要求 | Bit | 未设置(默认值) | 设置(整数值) |
|---|---|---|---|
| 搜索机密属性值所需的加密会话 | 0 | 0 (强制执行) | 1 (已禁用) |
| 修改现有机密属性值所需的加密会话 | 1 | 0 (强制执行) | 2 (已禁用) |
| 添加具有机密属性值的对象所需的加密会话 | 2 | 0 (强制执行) | 4 (已禁用) |
有关详细信息 dsHeuristics,请参阅 6.1.1.2.4.1.2 dSHeuristics。
AD DS 启动时,它会检查 dsHeuristics。 如果禁用了任何加密会话要求,则会记录相应的事件来记录该事实。 下表列出了这些事件、相应的禁用要求以及被设置dsHeuristics抑制的事件。
| 事件编号 | 相应dsHeuristic设置的效果 |
已取消的事件 ID |
|---|---|---|
| 3076 | 对机密属性的搜索不需要加密会话 | 3079 |
| 3077 | 修改现有机密属性不需要加密会话 | 3080 |
| 3078 | 无需加密会话即可添加具有机密属性的对象 | 3081 |
事件 ID 3076 的详细信息
Log Name: Directory Service
Source: Microsoft-Windows-ActiveDirectory_DomainService
Event ID: 3076
Task Category: Security
Level: Warning
Keywords: Classic
User: contoso\admin
Computer: dc25.contoso.com
Description:
The directory has been configured to return confidential attributes for LDAP search requests on unencrypted LDAP connections. No events will be logged and no requests will be blocked.
This setting is not secure and should only be used as a temporary step.
事件 ID 3077 的详细信息
Log Name: Directory Service
Source: Microsoft-Windows-ActiveDirectory_DomainService
Event ID: 3077
Task Category: Security
Level: Warning
Keywords: Classic
User: contoso\admin
Computer: dc25.contoso.com
Description:
The directory has been configured to allow modifying confidential attributes on unencrypted LDAP connections. No events will be logged and no requests will be blocked.
This setting is not secure and should only be used as a temporary step.
事件 ID 3078 的详细信息
Log Name: Directory Service
Source: Microsoft-Windows-ActiveDirectory_DomainService
Event ID: 3078
Task Category: Security
Level: Warning
Keywords: Classic
User: contoso\admin
Computer: dc25.contoso.com
Description:
The directory has been configured to allow adding new objects with confidential attributes on unencrypted LDAP connections. No events will be logged and no requests will be blocked.
This setting is not secure and should only be used as a temporary step.
更深入的调查
重要
此部分(或称方法或任务)介绍了修改注册表的步骤。 如果您错误地修改注册表,可能会出现严重问题。 因此,请确保仔细执行这些步骤。 出于防范目的,请在修改之前备份注册表,以便在出现问题时还原注册表。 有关如何备份和恢复注册表的更多信息,请参见如何在 Windows 中备份和恢复注册表。
对于查询,如果要验证客户端是否使用未加密的会话,可以将事件 ID 3079 与现场工程事件 ID 1644 相关联。 若要启用详细日志记录并最大化查询生成的事件信息,请在 Windows 命令提示符处运行以下命令:
reg add "hklm\system\currentcontrolset\services\ntds\parameters" /v "Expensive Search Results Threshold" /t reg_dword /d 00000001 /f
reg add "hklm\system\currentcontrolset\services\ntds\parameters" /v "Inefficient Search Results Threshold" /t reg_dword /d 00000001 /f
reg add "hklm\system\currentcontrolset\services\ntds\parameters" /v "Search Time Threshold (msecs)" /t reg_dword /d 00000001 /f
reg add "hklm\system\currentcontrolset\services\ntds\diagnostics" /v "15 Field Engineering" /t reg_dword /d 00000005 /f
当这些设置生效时,AD DS 的所有 LDAP 查询都会生成事件 ID 1644 的实例。 若要支持增加的日志信息,请考虑增加目录服务日志的最大大小。
若要继续前面的示例,对“cn”和“ms-Mcs-AdmPwd”的查询将生成事件 ID 3079,后跟事件 ID 1644。 事件 ID 1544 类似于以下示例:
Log Name: Directory Service
Source: Microsoft-Windows-ActiveDirectory_DomainService
Event ID: 1644
Task Category: Field Engineering
Level: Information
Computer: dc25.contoso.com
Description:
Internal event: A client issued a search operation with the following options.
Client:
10.32.51.5:54994
Starting node:
DC=contoso,DC=com
Filter:
(objectCategory=CN=Computer,CN=Schema,CN=Configuration,DC=contoso,DC=com)
Search scope:
subtree
Attribute selection:
ms-Mcs-AdmPwd,cn
...
User:
Contoso\Admin
您可能还会看到事件 ID 2041。 此事件指示取消重复的日志条目。 事件内容类似于以下示例:
Log Name: Directory Service
Source: Microsoft-Windows-ActiveDirectory_DomainService
Event ID: 2041
Task Category: Internal Processing
Level: Information
Computer: dc25.contoso.com
Description:
Duplicate event log entries were suppressed.
See the previous event log entry for details. An entry is considered a duplicate if the event code and all its insertion parameters are identical. The time period for this run of duplicates is from the time of the previous event to the time of this event.
Event Code:
80000c07
Number of duplicate entries:
7
在此上下文中,这些事件中的信息指示以下行为:
- 请求尝试检查八个 AD DS 对象中的每一个机密属性。
- 对于八个对象中的每一个,查询结果省略机密属性。
若要标识使用未加密会话的客户端,请交叉引用事件 ID 3079 中的用户详细信息到查询、事件 ID 1644 中的端口详细信息以及客户端 IP 地址。
若要在完成调查后关闭详细日志记录,请运行以下命令:
reg delete "hklm\system\currentcontrolset\services\ntds\parameters" /v "Expensive Search Results Threshold" /f
reg delete "hklm\system\currentcontrolset\services\ntds\parameters" /v "Inefficient Search Results Threshold" /f
reg delete "hklm\system\currentcontrolset\services\ntds\parameters" /v "Search Time Threshold (msecs)" /f
reg add "hklm\system\currentcontrolset\services\ntds\diagnostics" /v "15 Field Engineering" /t reg_dword /d 00000000 /f