Kestrel 与多个用户一起使用 Microsoft.AspNetCore.Authentication.Negotiate

Kestrel using Microsoft.AspNetCore.Authentication.Negotiate with multiple users

Microsoft.AspNetCore.Authentication.Negotiate 文档说明了以下 here 关于如何配置 Kestrel 以使用 Windows 身份验证:

The Microsoft.AspNetCore.Authentication.Negotiate component performs User Mode authentication. Service Principal Names (SPNs) must be added to the user account running the service, not the machine account. Execute setspn -S HTTP/myservername.mydomain.com myuser in an administrative command shell.

效果很好。但是没有说明如果不同用户下有多个运行的应用怎么办。如果我尝试执行 setspn -S HTTP/myservername.mydomain.com myuser; setspn -S HTTP/myservername.mydomain.com myuser2,我会得到错误 Duplicate SPN found, aborting operation!

我在注册 SPN (setspn -S HTTP/myservername.mydomain.com:5000 myuser) 时尝试使用该端口,但该注册似乎被忽略了。

是否不能运行两个asp.net具有windows身份验证的核心应用程序在不同用户下的同一服务器上,或者我必须以不同方式注册吗?

服务主体名称在 Active Directory 中必须是唯一的,并且只能关联到单个服务帐户。

SPN 是根据它们所连接的主机名确定的,因此

https://foo.bar.com 等同于 https://foo.bar.com:8234/baz

为了完整起见,如果 foo.bar.com 是 CNAME 记录,浏览器实际上将使用规范的 A 记录(例如 foo.bar.com => srv1-ny-web.corp.bar.net 将在搜索SPN).

您有两个选择:运行 在单独的(子)域上或对两者使用相同的帐户。对两者使用相同的帐户与使用计算机帐户相同。为了进一步相似,请使用 gMSA 帐户,这样您就不必管理密码了。