Question

We have a Java application (web-server) that can serve out an AS400 (IBM i) Profile Token Credential for an authorised user, generated using the JT Open package (which ends up as an alphanumeric string). We can pass this profile token to other java applications so they can use it to make a connection without us having to pass around user/password or have multiple copies of user/password in config files on each client PC.

We now need to call a legacy VB application (VB6) that currently requires a user/password but we want to be able to pass it a Profile Token Credential instead. The VB program uses OLE DB (ADODB object) to make a connection to the AS400; e.g. current code...

oCN = New ADODB.Connection
oCN.Open "Provider=IBMDA400;Data Source=AS400SERVERNAME;Force Translate=0", USER, PASSWORD

...what we would like is to change this to...

oCN = New ADODB.Connection
oCN.Open "Provider=IBMDA400;Data Source=AS400SERVERNAME;Force Translate=0", TOKEN

...or similar.

I've looked in the v7R1 IBM i Access for Windows OLE DB technical reference and I cannot see any mention of profile token credentials. The MS docs only mention user/password too (http://msdn.microsoft.com/en-us/library/windows/desktop/ms676505(v=vs.85).aspx).

What I'd like to know is whether anyone has used Profile Token Credentials with OLE DB/ADO or any other Visual Basic 6.0 compatible database technology, and if they have, do you have any documentation, examples or references you could share?

BTW - If the token technology cannot be used with VB6 but could be used with VB.NET, then we would also be interested in hearing how that would be done.

Was it helpful?

Solution

You can use a common minimum authority profile to perform the initial connection and then call the QSYSETPT API to adopt a specific profile using the token.

cnn = New ADODB.Connection
cnn.Open "Provider=IBMDA400;Data Source=AS400SERVERNAME;Force Translate=0", USER, PASS
cmd = New ADODB.Command
cmd.ActiveConnection = cnn
cmd.CommandType = adCmdText
cmd.CommandText = "{{CALL QSYSETPT(?,?)}}"
cmd.Parameters.Append
    cmd.CreateParameter(, adBinary, adParamInput, 32, token)
cmd.Parameters.Append 
    cmd.CreateParameter(, adInteger, adParamInputOutput, 4, 0)
cmd.Execute
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top