c# - Identity Server 中的 PrincipalContext.ValidateCredentials 与 HttpContext.AuthenticateAsync 有什么区别
问题描述
我通过调用HttpContext.AuthenticateAsync
ExternalController 在 Identity Server 中使用 Windows 帐户实现了 SSO,就像 Identity Server MVC 代码中已经存在的默认代码一样(请参阅此代码)。这一切都很好。
在其他一些代码中,我找到了另一种方法,我想知道他们为什么这样做。基本上,他们所做的是验证凭据,AccountController
如下所示:
using (var principalContext = new PrincipalContext(ContextType.Domain, domainName))
{
return principalContext.ValidateCredentials(userName, password);
}
...如果验证成功,他们会:
await httpContext.SignInAsync(username, username, new AuthenticationProperties());
所以我的问题是:这两种方法有什么区别,哪一种是针对 Windows 对用户进行身份验证的推荐方法?
解决方案
推荐阅读
- flutter - Flutter 小部件测试 - 未连接键盘
- python - 将大量大型列表写入文件
- python - 是否可以让一些轴标签覆盖 matplotlib 图中的多个列?
- c - cs50 pset 4 filter blur [only one test passes]
- android - Getting X and Y coordinate of android screen using accessibility services
- javascript - Update data using firestore cloud function
- python - Embedding Gifs in Discord Bot
- c# - 当 SSIS 中的 C# 转换需要同步时,在输出缓冲区中使用 AddRow()?
- javascript - 从变量(从导入的 JS)中获取字符串作为对象中的键
- mysql - MySQL "join on like" does not utilize INDEX