适用于 Windows 的网络访问验证算法和示例

您所在的位置:网站首页 验证协议内部错误 适用于 Windows 的网络访问验证算法和示例

适用于 Windows 的网络访问验证算法和示例

2024-07-01 15:52| 来源: 网络整理| 查看: 265

适用于 Windows Server 2003、Windows XP 和 Windows 2000 的网络访问验证算法和示例 项目12/26/2023

本文介绍如何在使用 NTLM 协议进行网络访问期间观察 Windows 帐户验证。

原始 KB 编号: 103390

摘要

下面是一种简化的算法,说明如何使用 NTLM 协议在网络访问期间观察 Windows 帐户验证的功能。 它使用通过服务器消息块 (SMB) 协议进行访问作为示例,但它适用于支持 NTLM 身份验证的所有其他服务器应用程序。 此讨论不涉及此过程的内部工作。 利用此信息,可以在确定性条件下预测 Windows 网络登录行为。

使用 Kerberos 对用户进行身份验证并获取对服务器资源的访问权限时,此过程与 NTLM 的过程不同。

请记住,本地数据库是域数据库,也是域控制器上的唯一数据库。 但在其他服务器和所有计算机上,本地数据库与域控制器不同。

背景信息

当两台基于 Windows Server 2003、基于 Windows XP 或基于 Windows 2000 的计算机通过网络进行通信时,它们使用称为服务器消息块 (SMB) 的高级协议。 SMB 命令嵌入到传输协议中,例如 NetBIOS 增强的用户界面 (NetBEUI) 或 TCP/IP。 例如,当客户端计算机执行 NET USE 命令时,会发出“SMB 会话设置和 X”帧。

在 Windows 中,“会话设置”SMB 包括用户帐户、加密密码的哈希函数和登录域。 域控制器将检查所有这些信息,以确定客户端是否有权完成 NET USE 命令。

算法

Windows 客户端计算机将以下命令发送到服务器:

NET USE x: \\server\share

Windows 客户端计算机发送包含其登录域、用户帐户和密码的“会话设置”SMB。

服务器检查 SMB 指定的域名或计算机名称。 如果该名称是服务器自己的名称,则会运行以下算法:

It checks its own domain database or computer database for a matching account. If it finds a matching account then The SMB password is compared to the domain database password or the computer database password. If the password matches then The command completed successfully. If the password does NOT match then The user is prompted for a password. The password is retested as above. System error 1326 has occurred. Logon failure: unknown user name or bad password. End If it does NOT find the account in the domain Security Accounts Manager (SAM) database or computer SAM database then Guest permissions are tested. If the guest account is enabled The command completed successfully. If the guest account is disabled (* See Note a). The user is prompted for a password. System error 1326 has occurred. Logon failure: unknown user name or bad password. End

如果在 SMB 中指定的域是服务器信任的域,则会运行以下算法:

The server will do pass-through authentication. The network logon request will be sent to a server that has a domain controller role in the specified trusted domain.

如果未设置安全通道,则会运行以下算法:

The trusted domain controller checks its own domain database for a matching account. If the trusted domain controller finds a matching account, then NOT for Windows 2000 and later versions: It determines whether the account is a local or global account. If the account is local, then Guest permissions on the original server are tested. If the guest account is enabled The command completed successfully. If the guest account is disabled (* See Note 1) The user is prompted for a password. System error 1326 has occurred. Logon failure: unknown user name or bad password. End If the account is global (the only option for Active Directory) The SMB password is compared to the domain database password. If the password matches, then The command completed successfully. (* See Note 2) If the password does NOT match, then The user is prompted for a password. The password is retested as above. System error 1326 has occurred. Logon failure: unknown user name or bad password. End If the trusted domain controller does NOT find the account in the trusted domain controller database, then Guest permissions are tested on the original server, not the trusted domain. (* See Note 3) If the guest account is enabled The user will have original server guest access. The command completed successfully. If the guest account is disabled (* See Note 1) The user is prompted for a password. System error 1326 has occurred. Logon failure: unknown user name or bad password. End

重要

以下情况讨论客户端使用与服务器拥有或知道的用户域不同的方案。 协商 NTLMv2 身份验证协议时,存在这种不匹配问题。 v2 的 NTLM 使用密码盐,客户端在此盐中使用用户域。

当服务器获取信息并在本地数据库中找到用户时,服务器将使用 LOCAL 数据库的名称来计算盐和哈希。 因此,如果客户端发送的“源域”为空或未知域,则 salt 和密码哈希将不匹配。 在这些情况下,身份验证尝试将失败,出现“用户名未知或密码错误” (STATUS_LOGON_FAILURE) 错误。 尝试的审核事件将报告“密码错误”,符号STATUS_WRONG_PASSWORD。

示例事件:

日志名称:安全性 源:Microsoft-Windows-Security-Auditing 事件 ID:4625 任务类别:登录 级别:信息 关键字:审核失败 计算机:server-computer1 说明: 帐户登录失败。

主题:

安全 ID:NULL SID 帐户名称: - 帐户域: - 登录 ID:0x0

登录类型:3

登录失败的帐户:

安全 ID:NULL SID 帐户名称:ntadmin 帐户域:client-computer1

失败信息:

失败原因:用户名未知或密码错误。 状态:0xc000006d 子状态:0xc000006a ...

详细的身份验证信息:

登录过程:NtLmSsp 身份验证包:NTLM 传输服务: - 包名称 (NTLM 仅) : - 密钥长度:0

若要避免这种情况,必须在客户端上显式包含正确的域名。 对于工作组方案上的驱动器映射,如下所示: Net use x: \\server-computer1\data /u:server-computer1\ntadmin *

如果服务器未知 SMB 中指定的域(例如,如果已指定域,但服务器未将域识别为受信任的域或其域控制器),则运行以下算法:

It will check its own account database for a matching account If the server finds a matching account, then The SMB password is compared to the domain database password or the computer database password. If the password matches, then The command completed successfully. If the password does NOT match, then The user is prompted for a password. The password is retested as above. System error 1326 has occurred. Logon failure: unknown user name or bad password. End If it does NOT find the account in the domain database then guest permissions are tested. If the guest account is enabled The command completed successfully. If the guest account is disabled System error 1326 has occurred. Logon failure: unknown user name or bad password. End

如果在 SMB 中指定的域为 NULL,即未指定域,则运行以下算法:

The server will treat this as a local network logon. The server will test for a matching account in its own database. If it finds a matching account, then The SMB password is compared to the SAM database password. If the password matches, then The command completed successfully. If the password does NOT match, then The user is prompted for a password. The password is retested as above. System error 1326 has occurred. Logon failure: unknown user name or bad password. End If it does NOT find the account in the local SAM database AND LsaLookupRestrictIsolatedNameLevel=0 AND NeverPing=0, then (* See Note 4) The server will simultaneously ask each domain that it trusts whether it has account that matches the SMB account. The first trusted domain to reply is sent a request to perform pass-through authentication of the client information. The trusted domain will look in its own database. If an account that matches the SMB account is found, then The trusted domain determines whether the account is a local or global account. Not for Windows 2000 and later versions: If the account is local then Guest permissions on the original server are tested. If the guest account is enabled The command completed successfully. If the guest account is disabled The user will be prompted for a password. Regardless of what password is entered, the user will receive "Error 5: Access has been denied." End If the account is global (the only option for Active Directory) The password that was specified in the SMB is compared to the SAM database password. If the password matches, then The command completed successfully. If the password does NOT match, then The user is prompted for a password. The password is retested as above. System error 1326 has occurred. Logon failure: unknown user name or bad password. End If no trusted domains respond to the request to identify the account, then Guest permissions are tested on the original server, not the trusted server. If the guest account is enabled The command completed successfully. If the guest account is disabled System error 1326 has occurred. Logon failure: unknown user name or bad password. End 注释

如果来宾帐户被禁用,并且用户没有帐户,服务器仍将请求密码。 尽管没有密码满足其要求,但服务器仍会请求密码作为安全措施。 此安全措施可确保未经授权的用户无法区分帐户存在的情况和帐户不存在的情况。 无论帐户是否存在,始终都会提示用户输入密码。

此时,将从响应中的受信任域返回以下信息:域 SID、用户 ID、全局组成员身份、登录时间、注销时间、KickOffTime、全名、密码 LastSet、密码可以更改标志、密码必须更改标志、用户脚本、配置文件路径、主目录和错误密码计数。

如果在受信任的域上找不到任何帐户,则操作系统必须使用本地来宾帐户来保证针对服务器的身份验证行为一致。

有关如何使用 LsaLookupRestrictIsolatedNameLevel 和 NeverPing 注册表项限制受信任域中独立名称的查找和登录的详细信息,请参阅 如果在 Active Directory 域控制器上具有许多外部信任,则 Lsass.exe 进程可能会停止响应。

受信任域上的来宾帐户将永远不可用。

实际的内部过程比此处所述的算法复杂。

这些算法不讨论直通身份验证的实际机制。 有关详细信息,请参阅 Windows 中的 NTLM 用户身份验证

这些算法不讨论 Windows Server 2003、Windows XP 和 Windows 2000 中使用的密码加密过程。 从单向密码哈希派生的 BLOB (二进制大型对象) 作为身份验证请求的一部分发送。 此 BLOB 的内容将取决于为登录选择的身份验证协议。

本文不讨论 Microsoft 身份验证模块的内部工作。

这些算法假定来宾帐户在启用时没有密码。 默认情况下,来宾帐户在 Windows Server 2003、Windows XP 和 Windows 2000 中没有密码。 如果指定了来宾帐户密码,则 SMB 中发送的用户密码必须与该来宾帐户密码匹配。

示例

下面是这些算法的运行示例。

示例 1

使用 SCRATCH-DOMAIN 域帐户数据库中的相同帐户名和密码登录到计算机。 为 SCRATCH-DOMAIN 域的域控制器运行 NET USE \\SCRATCH 命令时,该命令将成功完成。 为信任 SCRATCH-DOMAIN 域的域控制器运行 NET USE \\NET 命令时,会收到以下错误消息:

发生了系统错误 1326。 登录失败: 用户名未知或密码错误。

\SCRATCH-DOMAIN\USER1 帐户对 \\NET 具有权限。

注意

此示例假定以下配置。

配置

具有本地安全机构的计算机:

-登录帐户:USER1 -Password: PSW1 -Login 域:LOCAL1

Active Directory 域控制器:

-服务器名称:NET -Domain:NET-DOMAIN -Trust:NET-DOMAIN 信任 SCRATCH-DOMAIN (因此, 可以向 SCRATCH-DOMAIN 上的帐户授予权限 NET- DOMAIN) 。

NET-DOMAIN 域:

NET-DOMAIN 域的域帐户数据库不包含 USER1 的帐户。 来宾帐户已禁用。

Windows Server 2003:

-服务器名称:SCRATCH -Domain:SCRATCH-DOMAIN -域数据库包含帐户:USER1 -域数据库包含密码:PSW1

在此示例中,计算机登录到其本地域,而不是计算机域帐户所在的 SCRATCH-DOMAIN 域。

示例 2

运行 NET USE x: \\NET\share 命令时,将执行以下步骤:

计算机在“会话设置”SMB 中发送以下内容:

account = “USER1” password = “PSW1” domain = “LOCAL1”

\\NET 服务器接收 SMB 并查看帐户名称。

服务器检查其本地域帐户数据库,但找不到匹配项。

然后,服务器检查 SMB 域名。

服务器不信任“LOCAL1”,因此服务器不会检查其受信任的域。

然后,服务器会检查其来宾帐户。

来宾帐户处于禁用状态,因此出现“系统错误 1326”。 登录失败:用户名未知或密码错误。“生成错误消息。

示例 3

运行 NET USE x: \\SCRATCH\share 命令时,将执行以下步骤:

计算机在“会话设置”SMB 中发送以下内容:

account = “USER1” password = “PSW1” domain = “LOCAL1”

\\SCRATCH 服务器接收 SMB 并检查帐户名称。

服务器检查其本地域帐户数据库并找到匹配项。

然后,服务器将 SMB 密码与域帐户密码进行比较。

密码匹配。

因此,将生成“命令成功完成”消息。 在示例 2 和示例 3 中,信任关系不可用。 如果计算机已登录到 SCRATCH-DOMAIN 域,则 NET USE x: \\NET\share 命令将成功。

理想的解决方案是让所有计算机都登录到域。 若要登录,用户必须指定域、帐户和密码。 执行此操作后,所有 NET USE -type 命令都将传递正确的域、帐户和密码信息。 管理员应尽量避免计算机和多个域上的重复帐户。 基于 Windows Server 2003、基于 Windows XP 和基于 Windows 2000 的计算机通过使用域之间的信任以及可以使用域数据库的成员来帮助避免此配置。

解决方法

在这些情况下可以使用一种解决方法。 在计算机中,可以运行以下命令:

NET USE X: \\NET\SHARE /USER:SCRATCH-DOMAIN\USER1 PSW1

在此命令中,如下所示:

\\NET = 要访问的域控制器的计算机名称。 \SHARE = 共享名称。 /USER:命令行参数,用于指定应在“会话设置”SMB 中指定的域、帐户和密码。 SCRATCH-DOMAIN = 用户帐户所在的域的域名。 \USER1 = 要对其验证的帐户。 PSW1 = 与域上的帐户匹配的密码。

有关此命令的详细信息,请在命令提示符处键入以下命令:

NET USE /? NULL 域名

Windows Server 2003、Windows XP 和 Windows 2000 中包含的 Microsoft SMB 客户端在“会话设置 SMB [x73]”SMB 中发送 NULL 域名。 Microsoft SMB 客户端通过指定登录域名和发送 NULL 字符(如果未在 NET USE 命令中指定域名)来处理域名。 Microsoft SMB 客户端还将展示示例 1 中所述的行为。

注意

默认域名在“DOMAIN =”行的 LANMAN.INI 文件中指定。 这可以通过开关使用 NET LOGON 命令重写/DOMAIN:。 SMB 中“NULL”通常有两种表示形式:零长度域名和由问号字符 ( ) 组成的一字节域名。 SMB 服务器先捕获问号并将其转换为 NULL,然后再将其传递给本地安全机构 (LSA) 。 疑难解答

排查网络访问问题的一个很好的提示是通过执行以下操作来启用审核。

Windows 2000 及更高版本的基于 Windows 2000 的域控制器 从域控制器上的管理工具中,启动 Active Directory 用户和计算机。 右键单击“ 域控制器 OU”,然后单击“ 属性”。 在“ 组策略 ”选项卡上,双击“ 默认域控制器策略”。 在策略编辑器中,依次单击“计算机设置”、“Windows 设置”、“安全设置”、“本地策略”和“审核策略”。 选择 “登录和帐户登录成功 ”选项和“ 失败” 选项。 Windows 2000 服务器和成员的域设置 从域控制器上的管理工具中,启动 Active Directory 用户和计算机。 右键单击域名,然后单击“ 属性”。 在“ 组策略 ”选项卡上,双击“ 默认域策略”。 在策略编辑器中,依次单击“计算机设置”、“Windows 设置”、“安全设置”、“本地策略”和“审核策略”。 选择 “登录和帐户登录成功 ”选项和“ 失败” 选项。 Windows 2000 服务器和成员的本地设置 从“管理工具”中,启动“本地安全策略”。 打开“审核策略”。 选择 “登录和帐户登录成功 ”选项和“ 失败” 选项。 现在,每当网络用户远程访问此服务器时,都会在事件查看器中记录审核线索。 若要在事件查看器中查看这些事件,请单击“日志”菜单中的“安全性”。

有关信任关系、直通身份验证、用户权限和域登录的详细信息,请参阅“Windows Server 2003 安全服务的技术概述”。

更多信息

基本上,相同的网络访问验证算法应用于 Windows Server 2008、Windows Server 2008 R2、Windows Server 2012、Windows Server 2012 R2。

这些 OS 在 SMB 中具有多个新功能。

Windows Server 2008

SMB 中的新增功能

适用于 Windows Server 2008 的文件服务

Windows Server 2012

服务器消息块概述


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3