从ASP.net应用程序连接到Analysis Service

问题描述:

我正在尝试实现ASP.net应用程序,该应用程序需要连接Microsoft Analysis Service(SSAS)才能从多维数据集以及维度中检索数据.

I am trying to implement ASP.net application which will need to connect Microsoft Analysis Service (SSAS) to retrive data from cube as well as dimensions.

    static void Main(string[] args)
    {
        StringBuilder connectionStringBuilder = new StringBuilder();
        connectionStringBuilder.Append("Data Source=MyDataSource;");
        connectionStringBuilder.Append("Initial Catalog=MyOlapDatabase;");
        connectionStringBuilder.Append(@"User Id=OlapServerMachineName\MyUserName;");
        connectionStringBuilder.Append("Password=MyPassword;");
        connectionStringBuilder.Append("Provider=MSOLAP.5;");
        connectionStringBuilder.Append("Persist Security Info=True;");
        connectionStringBuilder.Append("MDX Compatibility=1;");
        connectionStringBuilder.Append("Safety Options=2;");
        connectionStringBuilder.Append("MDX Missing Member Mode=Error;");
        connectionStringBuilder.Append("Update Isolation Level=2;");



        using (var connection = new AdomdConnection(connectionStringBuilder.ToString()))
        {
            connection.Open();

        }

    }

此代码引发以下异常

无法建立连接.确保服务器正在运行.

A connection cannot be made. Ensure that the server is running.

内部异常提示

无法从传输连接中读取数据:远程主机强行关闭了现有连接.

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

而内部异常的内部异常是

and inner exception of inner exception is

无法从传输连接中读取数据:远程主机强行关闭了现有连接.

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

另一方面,我可以使用相同的用户名和密码从Excel连接到此Analysis Service,如下所示

On the other hand, I can connect to this Analysis Service from Excel with the same user name and password as shown below

我尝试按照此处设置对Olap Server的HTTP访问>.通过IIS设置上的匿名身份验证,我可以成功连接.但是,当我禁用匿名"选项并启用基本身份验证"时,再次无法从客户端工具进行连接,但是Excel在基本身份验证"下工作正常.

I tried setting up HTTP access to Olap Server as described here. With anonymous authentication on IIS setting, I am able to connect successfully. But when I disable Anonymous option and enable Basic Authentication, again I am not able connect from my client tool but Excel is working fine with Basic Authentication.

但是尝试使用HTTP访问只是临时解决方案.我不想使用该选项.我希望能够像从客户端应用程序一样在excel中连接SSAS.

But trying to use HTTP access was just for temporary solution. I do not want to use that option. I want to be able connect SSAS like I can in excel from my client app.

我的问题是,我连接SSAS的实现(不起作用)和excel身份验证(可以正常工作)之间有什么区别?

My question is, what is the difference between my implementation to connect SSAS (does not work) and excel authentication (works perfect) ?

谢谢.

不要将用户名和密码放在连接字符串上,请尝试至少在此模拟程序中包装您的 .Open()函数调用:

Instead of putting the user and password on the connection string try wrapping at least your .Open() function call in this impersonator:

https://github.com/OlapPivotTableExtensions/OlapPivotTableExtensions/blob/master/OlapPivotTableExtensions/Impersonater.cs

与连接字符串上的密码相比,我获得的成功更大.

I have had more success with that than passwords on the connection string.

除非您希望包含它,否则您不需要msmdpump HTTP层.

You shouldn't need the msmdpump HTTP layer unless you prefer it be involved.