MicroStrategy ONE

Session Creation in a .NET Environment

If you are customizing MicroStrategy Web in a .NET environment, some of the customizations might require you to create a session for connecting to MicroStrategy Intelligence Server using .NET code. Examples of such customizations include running MicroStrategy within a .NET-based portal or integrating MicroStrategy Web with a Portal Server. This topic provides sample code, written in C#, to illustrate how to create a session in a .NET environment using a session creation bridge utility.

Requirements

In order for the sample code provided below to work as designed, MicroStrategy Web must be installed on the same machine on which you wish to run the sample code.

Deployment Steps

The following steps are required for the sample code provided below:

  1. Add references to the following DLLs in your .NET project:  

    • MBBRIBASLib.dll

      The default location is Web ASPx\bin in the MicroStrategy installation directory.

    • MLJBRINF.dll

      The default location is Web ASPx\bin in the MicroStrategy installation directory.

    • MLMGDINF.dll

      The default location is Web ASPx\bin in the MicroStrategy installation directory.

    • BridgeUtils.dll

      The default location is samples\DotNET\BridgeUtils in the MicroStrategy SDK installation directory.

    The default location for each DLL is listed above. If you have changed the default path for the MicroStrategy software installation, use the appropriate reference.

  2. Add the following code sample for creating a session in your custom code:

using MicroStrategy.Web.utils;

...

 //Sample for creating session

     String server = "intqe64-1";

     String project = "Gutenberg Feature Testing VMall";

     String login = "WebUnittest";

     String pwd = "";

     String sessionClass = "com.microstrategy.web.objects.WebIServerSession";

     String factoryClassName = "com.microstrategy.web.objects.WebObjectsFactory";

     String localeInfoClass = "com.microstrategy.utils.localization.LocaleInfo";

     String localeClass = "java.util.Locale";

     BridgeUtils bu = new BridgeUtils();

     //Create WebObjectsFactory

     Instance factory = (Instance) bu.InvokeStatic(factoryClassName, "getInstance", factoryClassName);

     //Create Locale

     Instance locale = (Instance)bu.InvokeStatic(localeInfoClass, "convertLCIDToJavaLocale", BridgeUtils.INT_TYPE_ARRAY, new Object[] { 2052 }, localeClass);

     //Create WebIServerSession

     Instance session = (Instance) factory.Invoke("getIServerSession", sessionClass);

     session.Invoke("setServerName", BridgeUtils.STRING_TYPE_ARRAY, new String[] { server });

     session.Invoke("setProjectName", BridgeUtils.STRING_TYPE_ARRAY, new String[] { project });

     session.Invoke("setLogin", BridgeUtils.STRING_TYPE_ARRAY, new String[] { login });

     session.Invoke("setPassword", BridgeUtils.STRING_TYPE_ARRAY, new String[] { pwd });

     session.Invoke("setAuthMode", BridgeUtils.INT_TYPE_ARRAY, new Object[] { 1 });

     session.Invoke("setLocale", new String[] { localeClass}, new Object[] { locale });

     String id = (String) session.Invoke("getSessionID");