基于 "System.Security.Principal" 的 c# 用户身份验证是否适用于 ADFS 和 Azure Active Directory?
Does c# user authentication based on "System.Security.Principal" works for ADFS and Azure Active Directory?
我正在开发一个 C# WPF 应用程序,它需要根据当前用户的 Windows 域登录对其进行授权。用户不需要输入他的 username/password,应用程序只是授权他,只要他的用户帐户是 运行 应用程序。
我通过简单地使用 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 服务器 Active Directory。
我的代码是否符合这些新技术?还是必须重做登录机制?
支持 ADFS 会带来额外的开销。您可以尝试以下方法之一:
我正在开发一个 C# WPF 应用程序,它需要根据当前用户的 Windows 域登录对其进行授权。用户不需要输入他的 username/password,应用程序只是授权他,只要他的用户帐户是 运行 应用程序。
我通过简单地使用 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 服务器 Active Directory。
我的代码是否符合这些新技术?还是必须重做登录机制?
支持 ADFS 会带来额外的开销。您可以尝试以下方法之一: