[829] | 1 | { **************************************************************
|
---|
| 2 | Package: XWB - Kernel RPCBroker
|
---|
| 3 | Date Created: Sept 18, 1997 (Version 1.1)
|
---|
| 4 | Site Name: Oakland, OI Field Office, Dept of Veteran Affairs
|
---|
| 5 | Developers: Danila Manapsal, Joel Ivey
|
---|
| 6 | Description: Silent Login functionality.
|
---|
| 7 | Current Release: Version 1.1 Patch 40 (January 7, 2005))
|
---|
| 8 | *************************************************************** }
|
---|
| 9 |
|
---|
| 10 | unit RpcSLogin;
|
---|
| 11 |
|
---|
| 12 | interface
|
---|
| 13 |
|
---|
| 14 | Uses
|
---|
| 15 | Sysutils, Classes, Messages, WinProcs, IniFiles,
|
---|
| 16 | Dialogs, Registry,
|
---|
| 17 | trpcb, ccowrpcbroker;
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | {------ TVistaSession------} //hold attributes of a session {p13}
|
---|
| 21 | {TVistaSession = class(TObject)
|
---|
| 22 | private
|
---|
| 23 | FServerIPAddress: string;
|
---|
| 24 | FDateTimeLogin: String;
|
---|
| 25 | FPollingInterval: integer;
|
---|
| 26 | public
|
---|
| 27 | property ServerIPAddresss: String;
|
---|
| 28 | property DateTimeLogin: String;
|
---|
| 29 | property PollingInterval (BAT): integer;
|
---|
| 30 | procedure CreateHandle;
|
---|
| 31 | function ValidateHandle;
|
---|
| 32 | end; }
|
---|
| 33 |
|
---|
| 34 | function SilentLogIn(SLBroker: TRPCBroker): boolean;
|
---|
| 35 | procedure GetUserInfo(ConnectedBroker: TRPCBroker);
|
---|
| 36 | procedure GetSessionInfo(ConnectedBroker: TRPCBroker);
|
---|
| 37 | procedure StartProgSLogin(const ProgLine: String; ConnectedBroker: TRPCBroker);
|
---|
| 38 | function CheckCmdLine(SLBroker: TRPCBroker): Boolean;
|
---|
| 39 |
|
---|
| 40 | implementation
|
---|
| 41 |
|
---|
| 42 | uses wsockc, loginfrm, rpcberr, seldiv, hash;
|
---|
| 43 |
|
---|
| 44 | //validate a/v codes
|
---|
| 45 | function ValidAVCodes(SLBroker: TRPCBroker): boolean;
|
---|
| 46 | begin
|
---|
| 47 | try
|
---|
| 48 | with SLBroker do
|
---|
| 49 | begin
|
---|
| 50 | Param[0].Value := Encrypt(LogIn.AccessCode + ';' + LogIn.VerifyCode);
|
---|
| 51 | Param[0].PType := literal;
|
---|
| 52 | RemoteProcedure := 'XUS AV CODE';
|
---|
| 53 | Call;
|
---|
| 54 | if Results[0] > '0' then
|
---|
| 55 | begin
|
---|
| 56 | Login.DUZ := Results[0];
|
---|
| 57 | Result := True;
|
---|
| 58 | end
|
---|
| 59 | else
|
---|
| 60 | begin
|
---|
| 61 | Result := False;
|
---|
| 62 | if Results[2] = '1' then Login.ErrorText := 'Expired Verify Code' //vcode needs changing;
|
---|
| 63 | else if Results[0] = '0' then Login.ErrorText :='Invalid Access/Verify Codes' //no valid DUZ returned;
|
---|
| 64 | else Login.ErrorText := Results[3];
|
---|
| 65 | end;
|
---|
| 66 | end;
|
---|
| 67 | except
|
---|
| 68 | raise
|
---|
| 69 | end;
|
---|
| 70 | end;
|
---|
| 71 |
|
---|
| 72 | //validate application Handle
|
---|
| 73 | function ValidAppHandle(SLBroker: TRPCBroker): boolean;
|
---|
| 74 | begin
|
---|
| 75 | Result := False;
|
---|
| 76 | try
|
---|
| 77 | with SLBroker do
|
---|
| 78 | begin
|
---|
| 79 | Param[0].Value := SLBroker.Login.LogInHandle;
|
---|
| 80 | Param[0].PType := literal;
|
---|
| 81 | RemoteProcedure := 'XUS AV CODE';
|
---|
| 82 | Call;
|
---|
| 83 | if StrToInt(SLBroker.Results[0]) > 0 then
|
---|
| 84 | begin
|
---|
| 85 | Login.DUZ := Results[0];
|
---|
| 86 | Result := True;
|
---|
| 87 | end
|
---|
| 88 | else if Results[2] = '1' then Login.ErrorText := 'Expired Verify Code' //vcode needs changing;
|
---|
| 89 | else if Results[0] = '0' then Login.ErrorText :='Invalid Access/Verify Codes' //no valid DUZ returned;
|
---|
| 90 | else Login.ErrorText := Results[3];
|
---|
| 91 | end;
|
---|
| 92 | except
|
---|
| 93 | raise
|
---|
| 94 | end;
|
---|
| 95 | end;
|
---|
| 96 |
|
---|
| 97 | function ValidNTToken(SLBroker: TRPCBroker): boolean;
|
---|
| 98 | begin
|
---|
| 99 | Result := False;
|
---|
| 100 | end;
|
---|
| 101 |
|
---|
| 102 | {IF 2, PASS CONTROL TO AUTHENTICATION PROXY - WHAT DOES IT NEED? }
|
---|
| 103 |
|
---|
| 104 | {:
|
---|
| 105 | This function is used to initiate a silent login with the RPCBroker. It uses the information
|
---|
| 106 | stored in the Login property of the TRPCBroker to make the connection.
|
---|
| 107 | }
|
---|
| 108 | function SilentLogIn(SLBroker: TRPCBroker): boolean;
|
---|
| 109 | begin
|
---|
| 110 | Result := False;
|
---|
| 111 | //determine if signon is needed
|
---|
| 112 | try
|
---|
| 113 | with SLBroker do begin
|
---|
| 114 | RemoteProcedure := 'XUS SIGNON SETUP';
|
---|
| 115 | Call;
|
---|
| 116 | SLBroker.Login.IsProductionAccount := False;
|
---|
| 117 | SLBroker.Login.DomainName := '';
|
---|
| 118 | if SLBroker.Results.Count > 7 then
|
---|
| 119 | begin
|
---|
| 120 | SLBroker.Login.DomainName := SLBroker.Results[6];
|
---|
| 121 | if SLBroker.Results[7] = '1' then
|
---|
| 122 | SLBroker.Login.IsProductionAccount := True;
|
---|
| 123 | end;
|
---|
| 124 | if Results.Count > 5 then //Server sent auto signon info.
|
---|
| 125 | if SLBroker.Results[5] = '1' then //User already logged in
|
---|
| 126 | begin
|
---|
| 127 | Result := True;
|
---|
| 128 | GetUserInfo(SLBroker);
|
---|
| 129 | exit;
|
---|
| 130 | end;
|
---|
| 131 | if Login.Mode = lmAVCodes then //Access & Verify codes authentication
|
---|
| 132 | if ValidAVCodes(SLBroker) then Result := True;
|
---|
| 133 | if Login.Mode = lmAppHandle then
|
---|
| 134 | if ValidAppHandle(SLBroker)then Result := True;
|
---|
| 135 | if Login.Mode = lmNTToken then
|
---|
| 136 | if ValidNTToken(SLBroker) then Result := True;
|
---|
| 137 | if Result and (not (SLBroker is TCCOWRPCBroker)) then
|
---|
| 138 | begin
|
---|
| 139 | //determine if user is multidivisional - makes calls to Seldiv.
|
---|
| 140 | LogIn.MultiDivision := MultDiv(SLBroker);
|
---|
| 141 | if not LogIn.MultiDivision then
|
---|
| 142 | begin
|
---|
| 143 | Result := True;
|
---|
| 144 | exit;
|
---|
| 145 | end;
|
---|
| 146 | if LogIn.PromptDivision then
|
---|
| 147 | Result := SelectDivision(LogIn.DivList, SLBroker)
|
---|
| 148 | else if Login.Division <> '' then
|
---|
| 149 | Result := SetDiv(Login.Division, SLBroker)
|
---|
| 150 | else
|
---|
| 151 | begin
|
---|
| 152 | Result := False;
|
---|
| 153 | Login.ErrorText := 'No Division Selected';
|
---|
| 154 | end;
|
---|
| 155 | if not Result then
|
---|
| 156 | exit;
|
---|
| 157 | end;
|
---|
| 158 | if Result then
|
---|
| 159 | GetUserInfo(SLBroker);
|
---|
| 160 | end;
|
---|
| 161 | except
|
---|
| 162 | exit;
|
---|
| 163 | end;
|
---|
| 164 | end;
|
---|
| 165 |
|
---|
| 166 | procedure GetUserInfo(ConnectedBroker: TRPCBroker); //get info for TVistaUser;
|
---|
| 167 | begin
|
---|
| 168 | with ConnectedBroker do
|
---|
| 169 | begin
|
---|
| 170 | try
|
---|
| 171 | RemoteProcedure := 'XUS GET USER INFO';
|
---|
| 172 | Call;
|
---|
| 173 | if Results.Count > 0 then
|
---|
| 174 | with ConnectedBroker.User do
|
---|
| 175 | begin
|
---|
| 176 | DUZ := Results[0];
|
---|
| 177 | Name := Results[1];
|
---|
| 178 | StandardName := Results[2];
|
---|
| 179 | Division := Results[3];
|
---|
| 180 | Title := Results[4];
|
---|
| 181 | ServiceSection := Results[5];
|
---|
| 182 | Language := Results[6];
|
---|
| 183 | DTime := Results[7];
|
---|
| 184 | if Results.Count > 8 then
|
---|
| 185 | Vpid := Results[8]
|
---|
| 186 | else
|
---|
| 187 | Vpid := '';
|
---|
| 188 | end;
|
---|
| 189 | except
|
---|
| 190 | end;
|
---|
| 191 | end;
|
---|
| 192 | end;
|
---|
| 193 |
|
---|
| 194 | procedure GetSessionInfo(ConnectedBroker: TRPCBroker); //get info for TVistaSession;
|
---|
| 195 | begin
|
---|
| 196 | with ConnectedBroker do //get info for TVistaSession;
|
---|
| 197 | begin
|
---|
| 198 | try
|
---|
| 199 | RemoteProcedure := 'XWB GET SESSION INFO';
|
---|
| 200 | Call;
|
---|
| 201 | if Results.Count > 0 then
|
---|
| 202 | begin
|
---|
| 203 | {VistaSession.Create;
|
---|
| 204 | with VistaSession do
|
---|
| 205 | begin
|
---|
| 206 | DUZ := Results[0]
|
---|
| 207 | //other properties follow
|
---|
| 208 | end;}
|
---|
| 209 | end;
|
---|
| 210 | except
|
---|
| 211 | end;
|
---|
| 212 | end;
|
---|
| 213 | end;
|
---|
| 214 |
|
---|
| 215 | {:
|
---|
| 216 | This procedure can be used to start a second application and pass on the command line the data
|
---|
| 217 | which would be needed to initiate a silent login using a LoginHandle value. It is assumed that
|
---|
| 218 | the command line would be read using the CheckCmdLine procedure or one similar to it as the form
|
---|
| 219 | for the new application was loaded. This procedure can also be used to start a non-RPCBroker
|
---|
| 220 | application. If the value for ConnectedBroker is nil, the application specified in ProgLine
|
---|
| 221 | will be started and any command line included in ProgLine will be passed to the application.
|
---|
| 222 | }
|
---|
| 223 | procedure StartProgSLogin(const ProgLine: String; ConnectedBroker: TRPCBroker);
|
---|
| 224 | var
|
---|
| 225 | StartupInfo: TStartupInfo;
|
---|
| 226 | ProcessInfo: TProcessInformation;
|
---|
| 227 | AppHandle: String;
|
---|
| 228 | CmndLine: String;
|
---|
| 229 | begin
|
---|
| 230 | FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
|
---|
| 231 | with StartupInfo do
|
---|
| 232 | begin
|
---|
| 233 | cb := SizeOf(TStartupInfo);
|
---|
| 234 | dwFlags := STARTF_USESHOWWINDOW;
|
---|
| 235 | wShowWindow := SW_SHOWNORMAL;
|
---|
| 236 | end;
|
---|
| 237 | CmndLine := ProgLine;
|
---|
| 238 | if ConnectedBroker <> nil then
|
---|
| 239 | begin
|
---|
| 240 | AppHandle := GetAppHandle(ConnectedBroker);
|
---|
| 241 | CmndLine := CmndLine + ' s='+ConnectedBroker.Server + ' p='
|
---|
| 242 | + IntToStr(ConnectedBroker.ListenerPort) + ' h='
|
---|
| 243 | + AppHandle + ' d=' + ConnectedBroker.User.Division;
|
---|
| 244 | end;
|
---|
| 245 | CreateProcess(nil, PChar(CmndLine), nil, nil, False,
|
---|
| 246 | NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);
|
---|
| 247 | end;
|
---|
| 248 |
|
---|
| 249 | {:
|
---|
| 250 | This procedure can be used to check whether the command line contains information on the broker
|
---|
| 251 | settings and can setup for a Silent Login using the LoginHandle value passed from another application.
|
---|
| 252 | This procedure would normally be called within the code associated with FormCreate event. It assumes
|
---|
| 253 | the Server, ListenerPort, Division, and LoginHandle values (if present) are indicated by s=, p=, d=, and
|
---|
| 254 | h=, respectively. The argument is a reference to the TRPCBroker instance to be used.
|
---|
| 255 | }
|
---|
| 256 | function CheckCmdLine(SLBroker: TRPCBroker): Boolean;
|
---|
| 257 | var
|
---|
| 258 | j: Integer;
|
---|
| 259 | begin
|
---|
| 260 | with SLBroker do
|
---|
| 261 | begin
|
---|
| 262 | for j := 1 to ParamCount do // Iterate through possible command line arguments
|
---|
| 263 | begin
|
---|
| 264 | if Pos('p=',ParamStr(j)) > 0 then
|
---|
| 265 | ListenerPort := StrToInt(Copy(ParamStr(j),
|
---|
| 266 | (Pos('=',ParamStr(j))+1),length(ParamStr(j))));
|
---|
| 267 | if Pos('s=',ParamStr(j)) > 0 then
|
---|
| 268 | Server := Copy(ParamStr(j),
|
---|
| 269 | (Pos('=',ParamStr(j))+1),length(ParamStr(j)));
|
---|
| 270 | if Pos('h=',ParamStr(j)) > 0 then
|
---|
| 271 | begin
|
---|
| 272 | Login.LoginHandle := Copy(ParamStr(j),
|
---|
| 273 | (Pos('=',ParamStr(j))+1),length(ParamStr(j)));
|
---|
| 274 | if Login.LoginHandle <> '' then
|
---|
| 275 | begin
|
---|
| 276 | KernelLogin := False;
|
---|
| 277 | Login.Mode := lmAppHandle;
|
---|
| 278 | end;
|
---|
| 279 | end;
|
---|
| 280 | if Pos('d=',ParamStr(j)) > 0 then
|
---|
| 281 | Login.Division := Copy(ParamStr(j),
|
---|
| 282 | (Pos('=',ParamStr(j))+1),length(ParamStr(j)));
|
---|
| 283 | end; // for
|
---|
| 284 | if Login.Mode = lmAppHandle then
|
---|
| 285 | Connected := True; // Go ahead and make the connection
|
---|
| 286 | Result := False;
|
---|
| 287 | if Connected then
|
---|
| 288 | Result := True;
|
---|
| 289 | end; // with SLBroker
|
---|
| 290 | end;
|
---|
| 291 |
|
---|
| 292 |
|
---|
| 293 | end.
|
---|
| 294 |
|
---|
| 295 |
|
---|