PRB: Cannot Administer Analysis Services by Using DSO in ASP.NET (823066)



The information in this article applies to:

  • Microsoft SQL Server 2000 Analysis Services
  • Microsoft Visual Basic .NET (2002)
  • Microsoft Visual Basic .NET (2003)

SYMPTOMS

When you try to use Microsoft Decision Support Objects (DSO) from an ASP.NET application to perform administrative tasks on a server that is running Analysis Services, you may receive an error similar to the following:

When connecting to the local computer that is running Analysis Services:

Cannot connect to the Analysis server on computer 'MyServer'. Connection to the server is lost


When connecting to a remote computer that is running Analysis Services:

Cannot open connection to Analysis server 'MyRemoteServer'. Error in data [Possible data corruption]

CAUSE

This behavior occurs for two separate reasons. One part of the issue involves the start permissions of the DSO ActiveX DLL. By default, the ActiveX DLLs are carried out in the ASP.NET worker process (Aspnet_wp.exe) under the ASPNET account, when called from an ASPX page.

The other part of the issue is, Aspnet_wp.exe uses a Multi-Threaded Apartment (MTA) model, while DSO uses a Single-Threaded Apartment (STA) model. With the ASP.NET application, the impersonation token is on one of the applications MTA threads and the STA COM component is accessed by a different thread (the single thread in its STA). Because the MTA threads impersonation token is not passed to the STA thread, the STA thread carries out under the security token associated with the Aspnet_wp.exe process.

WORKAROUND

To work around the problem, you must enable impersonation in the ASP.NET application. To do so, follow these steps:
  • To enable impersonation, add one of the following lines to the Web.Config file of the ASP.NET application:
    <identity impersonate="true" userName=""  password=""/>
    -or-
    <identity impersonate="true" />
  • To continue to use the impersonation token during and after the MTA to STA switch, add the following attribute to the <@Page> directive at the top of the HTML tab for the ASPX page:
    aspcompat="true"

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new Visual Basic ASP.NET Web Application.
  2. Add a reference to the Microsoft Decision Support Objects COM object. To do so, follow these steps:
    • Click Tools, and then click Add Reference....
    • In the Add Reference wizard, click the COM tab.
    • Locate, and then click to select Microsoft Decision Support Objects.
    • Click Select, and then click OK.
  3. From the Toolbox, drag a Button control onto the WebForm.
  4. Right-click the Button control, and then click Properties.
  5. In the Properties pane, change the button ID value to testButton, and change the Text value to Test Button.
  6. Add the following code to the testButton_Click method of the WebForm:
    ' Create a DSO.Server object.
            Dim oDsoServer As DSO.Server
            oDsoServer = New DSO.Server
            Try
                ' Try to connect to the server.
                oDsoServer.Connect("<Server Name>")
                ' Connection was successful, so display a message.
                Response.Write("Connection OK")
                ' We're finished with the server, so close it.
                oDsoServer.CloseServer()
            Catch ex As Exception
                ' Connection failed so display an error.
                Response.Write(ex.Message.ToString())
            End Try
    Note Replace <Server Name> with the Analysis Services server name.
  7. To run the application, click Debug, and then click Start.
  8. On the WebForm, click Test Button.

REFERENCES

For more information about impersonation in ASP.NET, visit the following MSDN Web site:

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconaspnetimpersonation.asp

For more information about COM component compatibility, visit the following MSDN Web site:

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcomcomponentcompatibility.asp

Modification Type:MajorLast Reviewed:8/6/2003
Keywords:kbweb kbAuthentication kberrmsg kbprb KB823066 kbAudDeveloper