I’m trying to set up a dashboard for some O365 data but when I use connect-msolservice from a New-UDInputField Endpoint block I get the following error:
Could not load type ‘System.IdentityModel.Tokens.JwtSecurityToken’ from assembly ‘System.IdentityModel.Tokens.Jwt, Version=5.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’
I can connect using the credentials normally so i think this is because it’s via the dashboard, it is hosted via IIS 10, .net 4.7.2 is installed.
This is likely a problem with the O365 module conflicting with the UD module. They both use the JWT assembly that is referenced in the error but one expects a different version that the one that is actually loaded. Are you importing the modules in a specific order at all?
I don’t explicitly import the MSOnline module as it loads when the command is first called (so after the UD module in this instance), I can try importing it explicitly before the UD module though. I’ll give that a try and see if it makes a difference.
Edit: Nope, same issue when importing MSOnline first.
Can you open a GitHub issue for this? I can take a peek at the MSOnline module to see if we can fix this in UD.
The PowerShell team is looking at streamlining how modules assembly loads like this work so hopefully in newer versions of PowerShell this will be handled automatically. Until then, I’ll have to sort out the versions between MSOnline and UD.
So, quick update.
I really wanted to get this to work since my helpdesk is begging for an easier way to reset MFA settings for our users.
What I did to test this is remove the System.IdentityModel.Tokens.Jwt.dll from the net472 directory under IIS. The version that comes with UD is 5.5. I let the system use the version that comes with MSOnline, which is 5.2. I did not copy the file from the default location into net472.
So far its working fine. I can use Connect-MSOLService to get to Azure AD.
Keep in mind, that I’m not doing any API stuff, and I’m using only Windows authentication for access to the dashboard, so YMMV.
I managed to get this to work by updating the assembly binding to exclude the version of System.IdentityModel.Tokens.Jwt that the Connect-MsolService was using. This worked. My updated assembly binding is:
I don’t know much about assemblies, bindings, web anything really so this may not work or apply to UD but I was hoping someone more knowledgeable than me would see if something like this would work. Or maybe tell me where to add these lines to test.
I’m guessing they would go to the web.config file, just not sure what versions I would put in there.
My environment is Azure App Service, using AzureADAuth.
So this seeeemmmms to have work for me, I’m able to import the module manually, Connect-MsolService (I’m using a -ADGraphAccessToken and -MsGraphAccessToken to connect). Then run Get-MsolPartnerContract and store that in a Cached variable.
I don’t know if other cmdlets or features will have issues but it’s a start I guess.
This is what my web.config file looks like now, using MSOnline version 1.1.183.57.