Author Topic: how to connect cognos10(NTLM) using vs2005 C# web applicaion  (Read 8917 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

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 =;
    //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 + "?'";

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

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.