Create an Analysis Services connection manager in SSIS. Then create a new C# script task in SSIS and add a reference to AMO (Microsoft.AnalysisServices). I usually do that by choosing Add Reference... Browse... then pasting "C:\Windows\assembly\GAC_MSIL\Microsoft.AnalysisServices\" then looking for the version that will be installed on the server where I will deploy this SSIS package. Then add "using Microsoft.AnalysisServices;" to the top of your code. Here's the Main() function:
public void Main()
{
// Get Server and Database name from DTS connection object
string sServer = "";
string sDatabase = "";
foreach (ConnectionManager oConn in this.Dts.Connections)
{
if (oConn.CreationName.StartsWith("MSOLAP"))
{
sServer = (string)oConn.Properties["ServerName"].GetValue(oConn);
sDatabase = (string)oConn.Properties["InitialCatalog"].GetValue(oConn);
break;
}
}
if (string.IsNullOrEmpty(sServer) || string.IsNullOrEmpty(sDatabase))
{
Dts.TaskResult = (int)ScriptResults.Failure;
throw new Exception("Could not find or parse the SSAS connection string");
}
Server oServer = new Server();
oServer.Connect(sServer);
Database oDB = oServer.Databases.FindByName(sDatabase);
if (oDB == null)
{
oServer.Disconnect();
Dts.TaskResult = (int)ScriptResults.Failure;
throw new Exception("Did not find expected SSAS database: " + sDatabase);
}
Dimension dim = oDB.Dimensions.GetByName("Employee");
string sDimensionID = dim.ID;
string sDatabaseID = oDB.ID;
MessageBox.Show(sDatabaseID + " - " + sDimensionID);
oServer.Disconnect();
Dts.TaskResult = (int)ScriptResults.Success;
}
Incidentally, I would recommend not mucking with building XMLA. Just use AMO to do the processing:
dim.Process(ProcessType.ProcessFull);
I don't know how to get the Database ID cleanly with a DMV against SSAS Tabular other than by shredding a bunch of XML. So I wouldn't recommend a linked server.