Я использую пакет NuGet Microsoft.AnalysisServices.retail.amd64
Ниже приведен код, который я использую:
Код: Выделить всё
using Microsoft.AnalysisServices.Tabular;
using System;
namespace AnalysisServicesRolesRetrieval
{
class Program
{
static void Main(string[] args)
{
// Your Analysis Services server name
string serverName = "asazure://eastus.asazure.windows.net/yourAnalysisServicesServerName";
// Authentication details
string userName = $"app:{config.AnalysisServiceSpnClientId}@{config.TenantId}";
string password = "SpnSecret";
// Connect to the server
var connStr = $"Provider=MSOLAP;Data Source={serverName};User ID={userName};Password={password};Persist Security Info=True;Impersonation Level=Impersonate;";
Server server = new Server();
server.Connect(connStr);
// Iterate through each database and model to list roles
foreach (Database db in server.Databases)
{
Console.WriteLine($"Database: {db.Name}");
foreach (Model model in db.Model)
{
Console.WriteLine($" Model: {model.Name}");
foreach (Role role in model.Roles)
{
Console.WriteLine($" Role: {role.Name}");
// List members of the role
foreach (RoleMember member in role.Members)
{
Console.WriteLine($" Member: {member.Name}");
}
}
}
}
// Disconnect from the server
server.Disconnect();
}
}
}Сообщение об ошибке >: $Exception {"Не удалось загрузить тип 'System.Runtime.Remoting.Messaging.CallContext' из сборки
'mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 '.":"System.Runtime.Remoting.Messaging.CallContext"} System.TypeLoadException
Я также вижу предупреждение ниже при сборке:
Код: Выделить всё
Severity: Warning(active)
Code: NU1701
Description: Package 'Microsoft.AnalysisServices.retail.amd64 19.84.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project.
Подробнее здесь: https://stackoverflow.com/questions/788 ... d-password