Passing User ID and Password to Startup Macro from Database Lookup
PASSPORT PC to Host, PASSPORT Web to Host
TN3270, TN5250, VT, SCO ANSI, Wyse 60
Is it possible to lookup UserID and Password information from a database and pass them to a startup macro?
Below is a sample macro that will lookup the UserID and Password from a Microsoft Access or SQL Server database based on the current computer name. The following criteria must be met for this macro to work:
A Microsoft Access or SQL Server database must be created with the following fields: Computer, Userid & Password.
Using ODBC, a System DSN must be configured on each workstation that will use the macro. This System DSN should be configured to use the appropriate database driver and will point to the database where the UserID and Password information exists.
A valid UID and PWD must be provided to the connection string variable.
Sub ZMain() Dim Text, ret, Comp, conn1, Source, Connect, Userid, PW 'Create the database object: Set conn1 = CreateObject("ADODB.Recordset")
'Set variable for computer name: Comp = Environ("COMPUTERNAME")
'Select record from Users table: Source = "SELECT * FROM Users WHERE (((Computer)= '" & Comp & " '));"
'Set variable for connection string to database using valid userid and password: Connect = "DSN=MySystemDSN;UID=admin;PWD=;"
'Open connection to database: conn1.Open Source, Connect
'Set variable for value of Userid field: Userid = conn1.Fields.Item("Userid").Value
'Set variable for value of Password field: PW = conn1.Fields("Password").Value
'Send retrieved data to host: SendHostKeys Userid SendHostKeys ("<ENTER>") WaitForNoX 10 SendHostKeys PW SendHostKeys ("<ENTER>")
'Close connection and reset database object: conn1.Close Set conn1 = Nothing End Sub |
Once the macro above has been created, it can be set as a startup macro by following
the steps below:
macro, user id, password, database, lookup, login