Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connecting VB to AS400

Status
Not open for further replies.

ferreiramarques

Programmer
Feb 28, 2003
8
PT
I'm using the following code to connect to an AS400. Everything works fine except when I need to login with a different userID. How can I force a signon when userID is different ?



Function test(database)
Set as400 = Nothing
as400.Define UCase(as400systems.DefaultSystem)
Set pgm.system = as400
If database <> &quot;XXX&quot; Then
pgm.system.UserID = UserName & &quot;Y&quot;
Else
pgm.system.UserID = UserName
End If
as400.Signon

End Function
 
Hi ferreiramarques,

Not knowing much about your pgm.system object OR the value of UserName prior to the function call, you might want to determine the current user's id prior to calling this function and pass it via a function parameter.

Example:

Code:
Function test(database, strUsername As String)
    Set as400 = Nothing
    as400.Define UCase(as400systems.DefaultSystem)
    Set pgm.system = as400
    If database <> &quot;XXX&quot; Then
        pgm.system.UserID = strUsername & &quot;Y&quot;
    Else
        pgm.system.UserID = strUsername
    End If
    as400.Signon

End Function
Jim Kraxberger
Developing Access solutions since 1995
 
Jim,
the function to determine the user works fine, my problem is when the database is different(If database <> &quot;XXX&quot;), I need to change the user name (from strUsername to strUsername & &quot;Y&quot;), to force the signon of AS400 to open, and logicaly ask for the password.
My problem is how to force the signon to open.

Thank's
 
You got me on that one. If AS/400 requires a &quot;Y&quot; to be appended to the UserID, then it should work as specified provided the &quot;Y&quot; switch is valid. I would think that there would need to be some kind of delimiter (such as a switch in DOS [&quot;/Y&quot;]) that would separate a valid userid (such as BPAY) from the optional database login dialog window display switch; otherwise, any userid ending in &quot;Y&quot; could trigger the login window.

Couple of Ideas:
1. Does either pgm.system or pgm objects have any other methods/properties that might force a login prompt?
2. Are you sure about just appending a &quot;Y&quot; to trigger a prompt? (Maybe it is a &quot; Y&quot; or a &quot;/Y&quot;?)
a. What about UserID = &quot;Y&quot;? (Forget about the username)
b. What about UserID = &quot;&quot;? (Does AS/400 ask for login?)
c. What about UserID = NULL? (DITTO)

Anyway, good luck with your hunting? Jim Kraxberger
Developing Access solutions since 1995
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top