Search code examples
.netwindowspowershellauthenticationadfs3.0

ADFS 3 MFA Authentication Provider is not able to register as custom authentication provider


When Running the command

$typeName = "MyAuthenticationProvider.CustomProvider, MyAuthenticationProvider , Version=1.0.0.0, Culture=neutral, PublicKeyToken=63710e27eb483f92" 

Register-AdfsAuthenticationProvider -TypeName $typeName -Name "MyAuthenticationProvider" -Verbose

Error I am getting is -

Register-AdfsAuthenticationProvider : The external authentication method MyAuthenticationProvider could not be loaded. Exception has been thrown by the target of an invocation.

Same dll worked fine in my previous setup of ADFS 3 but this time it is giving this error while registering the dll. I can see DLL is registered in the GAC in- C:\Windows\Microsoft.NET\assembly\GAC_MSIL\

Windows Server 2012 R2. Please suggest any idea to find the reason for this error. There is nothing in Event log and error detail in PowerShell is very limited. Just fyi- 1FA login is working fine and ADFS service is running and able to connect to AD.


Solution

  • I am adding the answer here so that others can get help from it if they face the similar issue.

    After adding so many logs I was able to find the issue. There was an unhandled exception in one of scenario in the constructor of MyAuthenticationProvider.

    ADFS tries to create the object of your authentication provider as soon as you try to register it.

    So the solution for anyone who faces this issue is - handle all the exception for all the scenario in the constructor of your AuthenticationProvider.