微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

初始化 <Windows Server 中 AD FS 的自定义身份验证方法 > 时出错

如何解决初始化 <Windows Server 中 AD FS 的自定义身份验证方法 > 时出错

我开发了用于自定义 AD FS MFA 的 c# DLL。所以我使用本教程中的 Build a Custom Authentication Method for AD FS in Windows Server

我使用这个 Power Shell 命令:

Set-Location "C:\Release"
[System.Reflection.Assembly]::Load("System.EnterpriseServices,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$publish.GacInstall("C:\Release\MFAAdapter.dll")
([System.Reflection.Assembly]::LoadFile("C:\Release\MFAAdapter.dll")).FullName
$typeName = "MFAAdapter.Adapter,MFAAdapter,Version=1.0.0.7,PublicKeyToken=23251ce4dd11647e,processorArchitecture=MSIL”
Register-AdfsAuthenticationProvider -TypeName $typeName -Name “MFA Adapter” -ConfigurationFilePath 'C:\Release\config.json'
net stop adfssrv
net start adfssrv

但在事件查看器上启动 ADFS 服务后出现此错误

An error occurred loading an authentication provider. Fix configuration errors using PowerShell 

cmdlets and restart the Federation Service. 
Identifier: MFA Adapter 
Context: Proxy device TLS pipeline 

Additional Data 
Exception details: 
An error occurred initializing the 'MFA Adapter' authentication provider.

但我的 DLL 已加载并进行身份验证。它还加载 TryEndAuthentication() 函数

为什么会出现这个错误

最后:调用OnAuthenticationPipelineLoad()函数还有一个问题。这样,这个函数根本就没有被调用,也不会加载配置文件(config.json)

public void OnAuthenticationPipelineLoad(IAuthenticationMethodConfigData configData)
    {
        try
        {
            if (configData != null || configData.Data != null)
            {
                using (StreamReader reader = new StreamReader(configData.Data,Encoding.UTF8))
                {
                    var config = reader.ReadToEnd();
                    var obj = JObject.Parse(config);
                    EventLog.WriteEntry(
                        "Application",String.Format("Config loaded for user:{0}. iKey:{1},user_name,bj["ikey"]]),EventLogEntryType.information);

                    var ikey = obj["ikey"].ToString();
                }
            }
            else
            {
                EventLog.WriteEntry(
                            "Application",String.Format("Error: configData is null for user:{0}",user_name),EventLogEntryType.Error);
                throw new ArgumentNullException();
            }
        }
        catch (Exception ex)
        {
            EventLog.WriteEntry(
                "Application",String.Format("Exception on OnAuthenticationPipelineLoad for user:{0}: {1}",ex.Message),EventLogEntryType.Error);
            throw new ArgumentException(ex.Message);
        }
    }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。