我们如何使用 C# 在 SharePoint 中获取当前身份验证模式

How do we get the current Authentication Mode in SharePoint using C#

我有一个共享点网站,它有不同的身份验证选项可供用户登录,例如 Windows、Trusted SAML 等

如何判断当前请求的认证方式是什么?

我试过 "SPSecurity.AuthenticationMode" 但它的值总是形式。

您需要通过 SPOriginalIssuerType 获取它 属性

var localClaimManager = SPClaimProviderManager.Local;
                if (localClaimManager != null)
                {
                    var issuerType=SPOriginalIssuers.GetIssuerType(localClaimManager.DecodeClaim(SPContext.Current.Web.CurrentUser.LoginName).OriginalIssuer);
                    //Write your logic based on the issuerType received
//https://docs.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.administration.claims.sporiginalissuertype?view=sharepoint-server

                }