If you are unable to create a new account, please email support@bspsoftware.com



MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

how to connect cognos10(NTLM) using vs2005 C# web applicaion

Started by adamwu, 19 May 2011 01:56:19 AM

Previous topic - Next topic


i create a vs2005 c# web application to control user access to cognos10, and use a sample code from IBM support, but it still doesn't work.  the security of cognos10 is using  NTLM. do i need to change any configuration of congnos10 to make it work?

i already give
c8CMS.Url = "http://congnos10:9300/p2pd/servlet/dispatch";

it just can't get cam_passsport when the program runs to this line "c8CMS.logon(xmlEncodedCredentials, null);". it always jumps to Exception

can anyone help me out?  and thanks for your help in advance.

the code is following,

public bool specificUserLogon(string userName, string userPassword, string userNamespace)
    System.Text.StringBuilder credentialXML = new System.Text.StringBuilder("<credential>" );
    credentialXML.AppendFormat( "<namespace>{0}</namespace>", userNamespace );
    credentialXML.AppendFormat( "<username>{0}</username>", userName );
    credentialXML.AppendFormat( "<password>{0}</password>", userPassword );
    credentialXML.Append( "</credential>" );

    //The csharp toolkit encodes the credentials
    string encodedCredentials = credentialXML.ToString ();
    xmlEncodedXML xmlEncodedCredentials = new xmlEncodedXML();
    xmlEncodedCredentials.Value = encodedCredentials;
    searchPathSingleObject[] emptyRoleSearchPathList = new searchPathSingleObject[0];   
    c8CMS.logon(xmlEncodedCredentials, null);
    cam_passsport = c8CMS.biBusHeaderValue.CAM.CAMPassport.id;
    //System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=JavaScript>alert('passsport = ' + cam_passsport)</SCRIPT>");
    return true;
  catch(System.Exception ex)
    Page.Response.Output.WriteLine("Error:  " + ex.Message.ToString());
    return false;
  //This method builds the JavaScript dynamically to be included in the
  //HTML page. The JavaScript sets the cam passport to the cookie.
private void buildJavaScript()
  string gatewayEndPoint = "window.location='http://<ServerName>/C84/cgi-bin/cognos.cgi";                 
  gatewayEndPoint = gatewayEndPoint + "?b_action=xts.run&m=portal/main.xts&o_b_action=xts.run&o_m=portal/cc.xts&o_m_tab=p'";

  string javaScriptCode = "document.cookie = 'cam_passport=" + cam_passsport + ";path=/'; " + gatewayEndPoint;
  Page.RegisterStartupScript("passsport","<script language=JavaScript>"+javaScriptCode+";</script>");