The CognosLogon() method handles the authentication to the Cognos Report Service. This method permits a BIBus API value to be set and connected to Cognos 8. We have stored our authentication values in our web solution’s web.config file. We’ll discuss how to retrieve these values in the section named – web.config.
Here is the example code to authenticate a user to Cognos 8. The code is appending encoded xml with the stored values from the web.config file. The Content Manager service’s .logon() method is passed the encoded xml and it will return a valid CAMPassportId. If the user fails to be authenticated then an error message is passed to a string variable, which can then be displayed to the end user.
public string CognosLogon(contentManagerService1 cmService, string NmSpace,string uid, string pwd)
{
string CAMPassportID;
string credentialXML;
credentialXML= "
credentialXML= credentialXML +"
credentialXML= credentialXML +"
try
{
xmlEncodedXML xmlPath = new xmlEncodedXML();
xmlPath.Value = credentialXML;
cmService.logon(xmlPath,new searchPathSingleObject[]{});
CAMPassportID = _cmService.biBusHeaderValue.CAM.CAMPassport.id.ToString();
return CAMPassportID;
}
catch (Exception ex)
{
return _ErrMsg = ex.Message.ToString();
}
}