【问题标题】:Does c# user authentication based on "System.Security.Principal" works for ADFS and Azure Active Directory?基于“System.Security.Principal”的 c# 用户身份验证是否适用于 ADFS 和 Azure Active Directory?
【发布时间】:2020-10-21 21:36:20
【问题描述】:

我正在开发一个 C# WPF 应用程序,该应用程序需要根据当前用户的 Windows 域登录来对其进行授权。用户不需要输入他的用户名/密码,只要他的用户帐户运行应用程序,应用程序就会授权他。

我通过简单地使用System.Security.Principal 查询当前用户的凭据来实现这一点,如下所示:

System.Security.Principal.WindowsIdentity CallerWindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent();
string username = CallerWindowsIdentity.Name;

// Then, I simply look up the username in my database

问题:今天我的客户要求我使其与来自 ADFS(Active Directory 联合服务)和 Azure Active Directory 的用户兼容。

我有点老派编码员。我的知识一直围绕着本地 Windows Server Active Directory。

我的代码会与这些新技术兼容吗?还是我必须重做登录机制?

【问题讨论】:

    标签: c# azure active-directory azure-active-directory windows-authentication


    【解决方案1】:

    支持 ADFS 会带来额外的开销。您可以尝试以下方法之一:

    1. 使用 MSAL SDK - Active Directory Federation Services support in MSAL.NET
    2. AD FS OpenID Connect/OAuth flows and Application Scenarios

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-18
      • 1970-01-01
      • 1970-01-01
      • 2015-01-11
      • 1970-01-01
      • 2016-10-02
      • 1970-01-01
      • 2021-10-29
      相关资源
      最近更新 更多