RPC Broker Silent Login Example

RPC Broker Help Home Silent Login Examples Silent Login

Example 1: lmAVCodes Here is an example of how to use Silent Login by passing the Access and Verify codes to the TVistaLogin class.

If brkrRPCBroker1.Connected is True, then Silent Login has worked. NOTE: For a demonstration using the lmAVCodes, please run the lmAVCodes_Demo.EXE located in the ..\BDK32\Samples\SilentSignOn directory.

Example 2: lmAppHandle

Here is an example of how to use Silent Login by passing an Application Handle to the TVistaLogin class.

The lmAppHandle mode of the Silent Login is used when an application starts up a second application. If the second application tests for arguments on the command line, it is possible for this application to be started and make a connection to the VistA M Server without user interaction.

An example of a procedure for starting a second application with data on the command line to permit a Silent Login using the LoginHandle provided by the first application is shown below. This is followed by a procedure that can be called in the processing related to FormCreate to use this command line data to initialize the TRPCBroker component for Silent Login. '''NOTE: It should be noted that the procedures shown here are included within the RpcSLogin unit, and can be used directly from there. '''

If the value for ConnectedBroker is nil, the application specified in ProgLine will be started and any command line included in ProgLine will be passed to the application.

In the second application, a call to the Broker should be made shortly after starting, since the LoginHandle passed in has a finite lifetime (approximately 20 seconds) during which it is valid for the Silent Login.

{btnStart is clicked to start the second application Test2.exe}

The following procedure (CheckCmdLine) would be called in the FormCreate code of the application being started to check for command line input, and if relevant to the Broker connection, to set it up.

This code assumes that s=, p=, d=, and h= are used in conjunction with the values for Server, ListenerPort, User.Division, and LoginHandle, respectively.

The command line might look like:

The TRPCB and RpcSLogin units would need to be included in the USES clause.

procedure CheckCmdLine(brkrRPCB: TRPCBroker); var j: integer; begin // Iterate through possible command line arguments for j := 0 to 15 do begin if ParamStr(j) <> '' then begin Form1.Memo1.Lines.Add(IntToStr(j) + ' ' + ParamStr(j)); end; if Pos('p=',ParamStr(j)) > 0 then begin brkrRPCB.ListenerPort := StrToInt(Copy(ParamStr(j), (Pos('=',ParamStr(j))+1),length(ParamStr(j)))); end; if Pos('s=',ParamStr(j)) > 0 then begin brkrRPCB.Server := Copy(ParamStr(j),(Pos('=',ParamStr(j))+1),length(ParamStr(j))); end; if Pos('h=',ParamStr(j)) > 0 then begin brkrRPCB.Login.LoginHandle := Copy(ParamStr(j),(Pos('=',ParamStr(j))+1),length(ParamStr(j))); if brkrRPCB.Login.LoginHandle <> '' then begin brkrRPCB.KernelLogIn := False; brkrRPCB.Login.Mode := lmAppHandle; end; end; if Pos('d=',ParamStr(j)) > 0 then begin brkrRPCB.Login.Division := Copy(ParamStr(j),(Pos('=',ParamStr(j))+1),length(ParamStr(j))); end; '''end; ''' For a demonstration using the lmAppHandle, please run the lmAppHandle_Demo.EXE located in the ..\BDK32\Samples\SilentSignOn directory.