Author Topic: how to connect cognos10(NTLM) using vs2005 C# web applicaion  (Read 5065 times)

Offline adamwu

  • Associate
  • **
  • Join Date: Apr 2011
  • Posts: 2
  • Forum Citizenship: +0/-0
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
Page.Response.Output.WriteLine("Error...

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)
{
  try
  {
    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;
  }
}//specificUserLogon   
     
  //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>");
     
}//buildJavaScript

Offline nmcdermaid

  • Senior Consultant
  • Community Leader
  • *****
  • Join Date: Apr 2010
  • Posts: 76
  • Forum Citizenship: +1/-0
Re: how to connect cognos10(NTLM) using vs2005 C# web applicaion
« Reply #1 on: 21 Jan 2013 09:06:57 pm »
At least post the actual error you are getting.

 


       
Twittear