Search code examples
c#sql-serverssasimpersonationadomd.net

ChangeEffectiveUser API (for user impersonation in SSAS) missing from AdomdConnection Class in ADOMD.Net


I've been trying to check the access of a user on a SQL Server Analysis Services (SSAS) server using impersonation.

AdomdConnection class has following instance method to accomplish the same:

public void ChangeEffectiveUser(string effectiveUserName)

Here is the MSDN documentation for the same.

I followed the NuGet package instructions here to add ADOMD.Net in my C# project but when I try to use the API then I don't see the API in intellisense at all.

try
{
    Console.WriteLine("Going to open ADOMD connection.");
    myconnect.Open();
    //below line doesn't compile
    myconnect.ChangeEffectiveUser(@"mydomainname\otherUserIamTryingToImpersonate");
    adomdCommand.ExecuteNonQuery();
    Console.WriteLine("Query executed successfully");
    Console.ReadLine();
}
catch (Exception ex)
{

    MessageBox.Show("error in connection");
}

It is giving compilation failure:

Error CS1061 'AdomdConnection' does not contain a definition for 'ChangeEffectiveUser' and no extension method 'ChangeEffectiveUser' accepting a first argument of type 'AdomdConnection' could be found (are you missing a using directive or an assembly reference?)

Am I missing something?


Solution

  • I was able to figure out that MS has changed the NuGet package for the latest ADOMD.Net release which came as part of SQL Server 2016. It is available on NuGet package here in the name of Unofficial.Microsoft.AnalysisServices.AdomdClient. Not sure why MS has taken this strategy to introduce a new package instead when they should have simply added a new version in the already existing NuGet package here in the name of Microsoft.AnalysisServices.AdomdClient.

    The moment I took reference of v13.x of Microsoft.AnalysisServices.AdomdClient.dll present in Unofficial.Microsoft.AnalysisServices.AdomdClient NuGet package my compilation error went away and I could see the API.