This is a sample script that is part of the various scripts that I use to login into a Cognos environment using SDK. Once the contentManagerService1 object has the logged in credentials, you can use it to perform any task such as automatically importing / exporting a package, create a new DSN, create a new skin, basically anything that you would use the portal / UI for.
Part of this script is taken from the original SDK sample code that is provided. I have just customized it for my own use in my environment.
Try
Dim m_CMS as New contentManagerService1
m_CMS.url = "http://localhost:9300/p2pd/servlet/dispatch"
Dim m_nmsp, m_uname, m_pwd as String
Dim credentialXML As StringBuilder
credentialXML = New StringBuilder("<credential>")
credentialXML.Append("<namespace>")
credentialXML.Append(m_nmsp)
credentialXML.Append("</namespace>")
credentialXML.Append("<username>")
credentialXML.Append(m_uname)
credentialXML.Append("</username>")
credentialXML.Append("<password>")
credentialXML.Append(m_pwd)
credentialXML.Append("</password>")
credentialXML.Append("</credential>")
Dim encodedCredentials As String = credentialXML.ToString()
Dim xmlEncodedCredentials As New xmlEncodedXML
xmlEncodedCredentials.Value = encodedCredentials
m_CMS.logon(xmlEncodedCredentials, Nothing)
MsgBox("Success in logon!")
Return True
Catch ex as Exception
MsgBox ex.Message
Return False
End Try
Part of this script is taken from the original SDK sample code that is provided. I have just customized it for my own use in my environment.
Try
Dim m_CMS as New contentManagerService1
m_CMS.url = "http://localhost:9300/p2pd/servlet/dispatch"
Dim m_nmsp, m_uname, m_pwd as String
Dim credentialXML As StringBuilder
credentialXML = New StringBuilder("<credential>")
credentialXML.Append("<namespace>")
credentialXML.Append(m_nmsp)
credentialXML.Append("</namespace>")
credentialXML.Append("<username>")
credentialXML.Append(m_uname)
credentialXML.Append("</username>")
credentialXML.Append("<password>")
credentialXML.Append(m_pwd)
credentialXML.Append("</password>")
credentialXML.Append("</credential>")
Dim encodedCredentials As String = credentialXML.ToString()
Dim xmlEncodedCredentials As New xmlEncodedXML
xmlEncodedCredentials.Value = encodedCredentials
m_CMS.logon(xmlEncodedCredentials, Nothing)
MsgBox("Success in logon!")
Return True
Catch ex as Exception
MsgBox ex.Message
Return False
End Try