ADOMD.Net Net 6 authentication issues

172 Views Asked by At

I'm trying to migrate an application from Net 4.x to Net 6 and I've stumbled about a weird situation. Basically I want to switch Microsoft.AnalysisServices.AdomdClient.retail.amd64 to Microsoft.AnalysisServices.AdomdClient.NetCore.retail.amd64 which from what I've seen is supposed to be used with Net 6.

The error in question:

MsalServiceException: AADSTS50052: The password entered exceeds the maximum length. Please reach out to your admin to reset the password.

I'm using Microsoft.AnalysisServices.AdomdClient.retail.amd64 in my Net 4.x which has a dependency on Microsoft.Identity.Client. The application calls power BI with a connection string that has Password={accessToken} which is my OnBehalfToken. On version 4.10, the connection works fine but If I upgrade the package to the latest version I now get the error that the password is too long. From what I've gathered the issue starts occurring after version 4.43.

The same behaviour is also in net core equivalent package Microsoft.AnalysisServices.AdomdClient.NetCore.retail.amd64 which as far as I can tell should be pretty much exactly the same. This particular package must have Microsoft.Identity.Client (=> 4.43.0)

The code kinda looks like this

        string ConnectionString = $"Provider=MSOLAP;Data Source={server};User ID=;Password={accessToken};Catalog={databaseName};Persist Security Info=True; Impersonation Level=Impersonate";

        using (AdomdConnection adomdConnection = new AdomdConnection())
        {
            adomdConnection.ConnectionString = ConnectionString;
            AdomdCommand adomdCommand = new AdomdCommand();
            adomdCommand.Connection = adomdConnection;                
            adomdCommand.CommandText = "SAMPLE QUERY";
            adomdConnection.Open(); // Fails AADSTS50052
            CellSet cellSet = adomdCommand.ExecuteCellSet();
            adomdConnection.Close();
        }

I don't understand why it's working on the older versions but won't on the latest version in 4.x or any version in Net 6.

Is there another way to accomplish this, or am I missing something obvious?

Thank you.

0

There are 0 best solutions below