| 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, Don Craven, Joel Ivey | 
|---|
| 6 | Description: Contains TRPCBroker and related components. | 
|---|
| 7 | Current Release: Version 1.1 Patch 47 (Jun. 17, 2008) | 
|---|
| 8 | *************************************************************** } | 
|---|
| 9 |  | 
|---|
| 10 | {************************************************** | 
|---|
| 11 | This is the hierarchy of things: | 
|---|
| 12 | TRPCBroker contains | 
|---|
| 13 | TParams, which contains | 
|---|
| 14 | array of TParamRecord each of which contains | 
|---|
| 15 | TMult | 
|---|
| 16 |  | 
|---|
| 17 | v1.1*4 Silent Login changes (DCM) 10/22/98 | 
|---|
| 18 |  | 
|---|
| 19 | 1.1*6 Polling to support terminating arphaned server jobs. (P6) | 
|---|
| 20 | == DPC 4/99 | 
|---|
| 21 |  | 
|---|
| 22 | 1.1*8 Check for Multi-Division users. (P8) - REM 7/13/99 | 
|---|
| 23 |  | 
|---|
| 24 | 1.1*13 More silent login code; deleted obsolete lines (DCM) 9/10/99  // p13 | 
|---|
| 25 | LAST UPDATED: 5/24/2001   // p13  JLI | 
|---|
| 26 |  | 
|---|
| 27 | 1.1*31 Added new read only property BrokerVersion to TRPCBroker which | 
|---|
| 28 | should contain the version number for the RPCBroker | 
|---|
| 29 | (or SharedRPCBroker) in use. | 
|---|
| 30 | **************************************************} | 
|---|
| 31 | unit CCOWRPCBroker; | 
|---|
| 32 |  | 
|---|
| 33 | interface | 
|---|
| 34 |  | 
|---|
| 35 | {$I IISBase.inc} | 
|---|
| 36 |  | 
|---|
| 37 | uses | 
|---|
| 38 | {Delphi standard} | 
|---|
| 39 | Classes, Controls, Dialogs, {DsgnIntf,} Forms, Graphics, Messages, SysUtils, | 
|---|
| 40 | WinProcs, WinTypes, Windows, | 
|---|
| 41 | extctrls, {P6} | 
|---|
| 42 | {VA} | 
|---|
| 43 | XWBut1, {RpcbEdtr,} MFunStr, Hash, | 
|---|
| 44 | ComObj, ActiveX, OleCtrls, trpcb, | 
|---|
| 45 | VERGENCECONTEXTORLib_TLB; | 
|---|
| 46 |  | 
|---|
| 47 | const | 
|---|
| 48 | NoMore: boolean = False; | 
|---|
| 49 | MIN_RPCTIMELIMIT: integer = 30; | 
|---|
| 50 | CURRENT_RPC_VERSION: String = 'XWB*1.1*36T1'; | 
|---|
| 51 |  | 
|---|
| 52 | type | 
|---|
| 53 |  | 
|---|
| 54 | TCCOWRPCBroker = class(TRPCBroker) | 
|---|
| 55 | private | 
|---|
| 56 | protected | 
|---|
| 57 | FCCOWLogonIDName: String; | 
|---|
| 58 | FCCOWLogonIDValue: String; | 
|---|
| 59 | FCCOWLogonName: String; | 
|---|
| 60 | FCCOWLogonNameValue: String; | 
|---|
| 61 | FContextor: TContextorControl;  //CCOW | 
|---|
| 62 | FCCOWtoken: string;              //CCOW | 
|---|
| 63 | FVistaDomain: String; | 
|---|
| 64 | FCCOWLogonVpid: String; | 
|---|
| 65 | FCCOWLogonVpidValue: String; | 
|---|
| 66 | FWasUserDefined: Boolean; | 
|---|
| 67 | //  procedure   SetConnected(Value: Boolean); override; | 
|---|
| 68 | function  GetCCOWHandle(ConnectedBroker: TCCOWRPCBroker): string; | 
|---|
| 69 | procedure CCOWsetUser(Uname, token, Domain, Vpid: string; Contextor: | 
|---|
| 70 | TContextorControl); | 
|---|
| 71 | function  GetCCOWduz( Contextor: TContextorControl): string; | 
|---|
| 72 | public | 
|---|
| 73 | function GetCCOWtoken(Contextor: TContextorControl): string; | 
|---|
| 74 | function IsUserCleared: Boolean; | 
|---|
| 75 | function WasUserDefined: Boolean; | 
|---|
| 76 | function IsUserContextPending(aContextItemCollection: IContextItemCollection): | 
|---|
| 77 | Boolean; | 
|---|
| 78 | property   Contextor: TContextorControl | 
|---|
| 79 | read Fcontextor write FContextor;  //CCOW | 
|---|
| 80 | property CCOWLogonIDName: String read FCCOWLogonIDName; | 
|---|
| 81 | property CCOWLogonIDValue: String read FCCOWLogonIDValue; | 
|---|
| 82 | property CCOWLogonName: String read FCCOWLogonName; | 
|---|
| 83 | property CCOWLogonNameValue: String read FCCOWLogonNameValue; | 
|---|
| 84 | property CCOWLogonVpid: String read FCCOWLogonVpid; | 
|---|
| 85 | property CCOWLogonVpidValue: String read FCCOWLogonVpidValue; | 
|---|
| 86 | published | 
|---|
| 87 | property    Connected: boolean read FConnected write SetConnected; | 
|---|
| 88 | end; | 
|---|
| 89 |  | 
|---|
| 90 | procedure AuthenticateUser(ConnectingBroker: TCCOWRPCBroker); | 
|---|
| 91 |  | 
|---|
| 92 | implementation | 
|---|
| 93 |  | 
|---|
| 94 | uses | 
|---|
| 95 | Loginfrm, RpcbErr, WSockc, SelDiv{p8}, RpcSLogin{p13}, fRPCBErrMsg, | 
|---|
| 96 | CCOW_const; | 
|---|
| 97 |  | 
|---|
| 98 | var | 
|---|
| 99 | CCOWToken: String; | 
|---|
| 100 | Domain: String; | 
|---|
| 101 | PassCode1: String; | 
|---|
| 102 | PassCode2: String; | 
|---|
| 103 |  | 
|---|
| 104 |  | 
|---|
| 105 | {--------------------- TCCOWRPCBroker.SetConnected -------------------- | 
|---|
| 106 | ------------------------------------------------------------------ | 
|---|
| 107 | procedure TCCOWRPCBroker.SetConnected(Value: Boolean); | 
|---|
| 108 | var | 
|---|
| 109 | BrokerDir, Str1, Str2, Str3 :string; | 
|---|
| 110 | RPCBContextor: TContextorControl; | 
|---|
| 111 | UseSSH: TSecure; | 
|---|
| 112 | ParamVal: String; | 
|---|
| 113 | ParamNum: Integer; | 
|---|
| 114 | PseudoServer: String; | 
|---|
| 115 | PseudoPortStr: String; | 
|---|
| 116 | PseudoPort: Integer; | 
|---|
| 117 | begin | 
|---|
| 118 | RPCBError := ''; | 
|---|
| 119 | Login.ErrorText := ''; | 
|---|
| 120 | if (Connected <> Value) and not(csReading in ComponentState) then begin | 
|---|
| 121 | if Value and (FConnecting <> Value) then begin                 {connect | 
|---|
| 122 | FSocket := ExistingSocket(Self); | 
|---|
| 123 | FConnecting := True; // FConnected := True; | 
|---|
| 124 | try | 
|---|
| 125 | if FSocket = 0  then | 
|---|
| 126 | begin | 
|---|
| 127 | {Execute Client Agent from directory in Registry. | 
|---|
| 128 | BrokerDir := ReadRegData(HKLM, REG_BROKER, 'BrokerDr'); | 
|---|
| 129 | if BrokerDir <> '' then | 
|---|
| 130 | ProcessExecute(BrokerDir + '\ClAgent.Exe', sw_ShowNoActivate) | 
|---|
| 131 | else | 
|---|
| 132 | ProcessExecute('ClAgent.Exe', sw_ShowNoActivate); | 
|---|
| 133 | if DebugMode and (not OldConnectionOnly) then | 
|---|
| 134 | begin | 
|---|
| 135 | Str1 := 'Control of debugging FOR UCX OR NON-CALLBACK CONNECTIONS has been moved from the client to the server. To start a Debug session, do the following:'+#13#10#13#10; | 
|---|
| 136 | Str2 := '1. On the server, set initial breakpoints where desired.'+#13#10+'2. DO DEBUG^XWBTCPM.'+#13#10+'3. Enter a unique Listener port number (i.e., a port number not in general use).'+#13#10; | 
|---|
| 137 | Str3 := '4. Connect the client application using the port number entered in Step #3.'; | 
|---|
| 138 | ShowMessage(Str1 + Str2 + Str3); | 
|---|
| 139 | end; | 
|---|
| 140 |  | 
|---|
| 141 | CheckSSH; | 
|---|
| 142 | if not (FUseSecureConnection = secureNone) then | 
|---|
| 143 | begin | 
|---|
| 144 | if not StartSecureConnection(PseudoServer, PseudoPortStr) then | 
|---|
| 145 | exit; | 
|---|
| 146 | //Val(PseudoPortStr,PseudoPort,Code) | 
|---|
| 147 | PseudoPort := StrToInt(PseudoPortStr); | 
|---|
| 148 | end | 
|---|
| 149 | else | 
|---|
| 150 | begin | 
|---|
| 151 | PseudoPort := ListenerPort; | 
|---|
| 152 | PseudoServer := Server; | 
|---|
| 153 | end; | 
|---|
| 154 | // 060920  end of addition | 
|---|
| 155 | TXWBWinsock(XWBWinsock).IsBackwardsCompatible := IsBackwardCompatibleConnection; | 
|---|
| 156 | TXWBWinsock(XWBWinsock).OldConnectionOnly := OldConnectionOnly; | 
|---|
| 157 | FSocket := TXWBWinsock(XWBWinsock).NetworkConnect(DebugMode, PseudoServer, // {FServer, | 
|---|
| 158 | PseudoPort {ListenerPort, FRPCTimeLimit); | 
|---|
| 159 | //  060919 Prefix added to handle multiple brokers including old and new | 
|---|
| 160 | {              Prefix := TXWBWinsock(XWBWinsock).Prefix; | 
|---|
| 161 | FIsNewStyleConnection := TXWBWinsock(XWBWinsock).IsNewStyle; | 
|---|
| 162 | AuthenticateUser(Self); | 
|---|
| 163 | StoreConnection(Self);  //MUST store connection before CreateContext() | 
|---|
| 164 | //CCOW start | 
|---|
| 165 | if (FContextor <> nil) and (length(CCOWtoken) = 0) then | 
|---|
| 166 | begin | 
|---|
| 167 | //Get new CCOW token | 
|---|
| 168 | CCOWToken := GetCCOWHandle(Self); | 
|---|
| 169 | if Length(CCOWToken) > 0 then | 
|---|
| 170 | begin | 
|---|
| 171 | try | 
|---|
| 172 | RPCBContextor := TContextorControl.Create(Application); | 
|---|
| 173 | RPCBContextor.Run('BrokerLoginModule#', PassCode1+PassCode2, TRUE, '*'); | 
|---|
| 174 | CCOWsetUser(user.name, CCOWToken, Domain, user.Vpid, RPCBContextor);  //Clear token | 
|---|
| 175 | FCCOWLogonIDName := CCOW_LOGON_ID; | 
|---|
| 176 | FCCOWLogonIdValue := Domain; | 
|---|
| 177 | FCCOWLogonName := CCOW_LOGON_NAME; | 
|---|
| 178 | FCCOWLogonNameValue := user.name; | 
|---|
| 179 | if user.name <> '' then | 
|---|
| 180 | FWasUserDefined := True; | 
|---|
| 181 | FCCOWLogonVpid := CCOW_LOGON_VPID; | 
|---|
| 182 | FCCOWLogonVpidValue := user.Vpid; | 
|---|
| 183 | RPCBContextor.Free; | 
|---|
| 184 | RPCBContextor := nil; | 
|---|
| 185 | except | 
|---|
| 186 | ShowMessage('Problem with Contextor.Run'); | 
|---|
| 187 | FreeAndNil(RPCBContextor); | 
|---|
| 188 | end; | 
|---|
| 189 | end;   // if Length(CCOWToken) > 0 | 
|---|
| 190 | end;  //if | 
|---|
| 191 | //CCOW end | 
|---|
| 192 | FPulse.Enabled := True; //P6 Start heartbeat. | 
|---|
| 193 | CreateContext('');      //Closes XUS SIGNON context. | 
|---|
| 194 | end | 
|---|
| 195 | else | 
|---|
| 196 | begin                     //p13 | 
|---|
| 197 | StoreConnection(Self); | 
|---|
| 198 | FPulse.Enabled := True; //p13 | 
|---|
| 199 | end;                      //p13 | 
|---|
| 200 | FConnected := True;         // jli mod 12/17/01 | 
|---|
| 201 | FConnecting := False; | 
|---|
| 202 | // 080620 If connected via SSH, With no command box | 
|---|
| 203 | //        visible, should let users know they have it. | 
|---|
| 204 | if not (CommandBoxProcessHandle = 0) then | 
|---|
| 205 | begin | 
|---|
| 206 | thisOwner := self.Owner; | 
|---|
| 207 | if (thisOwner is TForm) then | 
|---|
| 208 | begin | 
|---|
| 209 | thisParent := TForm(self.Owner); | 
|---|
| 210 | if not (Pos('(SSH Secure connection)',thisParent.Caption) > 0) then | 
|---|
| 211 | thisParent.Caption := thisParent.Caption + ' (SSH Secure connection)'; | 
|---|
| 212 | end; | 
|---|
| 213 | end; | 
|---|
| 214 | except | 
|---|
| 215 | on E: EBrokerError do begin | 
|---|
| 216 | if E.Code = XWB_BadSignOn then | 
|---|
| 217 | TXWBWinsock(XWBWinsock).NetworkDisconnect(FSocket); | 
|---|
| 218 | FSocket := 0; | 
|---|
| 219 | FConnected := False; | 
|---|
| 220 | FConnecting := False; | 
|---|
| 221 | if not (CommandBoxProcessHandle = 0) then | 
|---|
| 222 | TerminateProcess(CommandBoxProcessHandle,10); | 
|---|
| 223 | FRPCBError := E.Message;               // p13  handle errors as specified | 
|---|
| 224 | if Login.ErrorText <> '' then | 
|---|
| 225 | FRPCBError := E.Message + chr(10) + Login.ErrorText; | 
|---|
| 226 | if Assigned(FOnRPCBFailure) then       // p13 | 
|---|
| 227 | FOnRPCBFailure(Self)                 // p13 | 
|---|
| 228 | else if ShowErrorMsgs = semRaise then | 
|---|
| 229 | Raise;                               // p13 | 
|---|
| 230 | //          raise;   {this is where I would do OnNetError | 
|---|
| 231 | end{on; | 
|---|
| 232 | end{try; | 
|---|
| 233 | end{if | 
|---|
| 234 | else if not Value then | 
|---|
| 235 | begin                           //p13 | 
|---|
| 236 | FConnected := False;          //p13 | 
|---|
| 237 | FPulse.Enabled := False;      //p13 | 
|---|
| 238 | if RemoveConnection(Self) = NoMore then begin | 
|---|
| 239 | {FPulse.Enabled := False;  ///P6;p13 | 
|---|
| 240 | TXWBWinsock(XWBWinsock).NetworkDisconnect(Socket);   {actually disconnect from server | 
|---|
| 241 | FSocket := 0;                {store internal | 
|---|
| 242 | //FConnected := False;      //p13 | 
|---|
| 243 | // 080618 following added to close command box if SSH is being used | 
|---|
| 244 | if not (CommandBoxProcessHandle = 0) then | 
|---|
| 245 | begin | 
|---|
| 246 | TerminateProcess(CommandBoxProcessHandle,10); | 
|---|
| 247 | thisOwner := self.Owner; | 
|---|
| 248 | if (thisOwner is TForm) then | 
|---|
| 249 | begin | 
|---|
| 250 | thisParent := TForm(self.Owner); | 
|---|
| 251 | if (Pos('(SSH Secure connection)',thisParent.Caption) > 0) then | 
|---|
| 252 | begin | 
|---|
| 253 | // 080620 remove ' (SSH Secure connection)' on disconnection | 
|---|
| 254 | thisParent.Caption := Copy(thisParent.Caption,1,Length(thisParent.Caption)-24); | 
|---|
| 255 | end; | 
|---|
| 256 | end; | 
|---|
| 257 | end; | 
|---|
| 258 | end{if; | 
|---|
| 259 | end; {else | 
|---|
| 260 | end{if; | 
|---|
| 261 | end; | 
|---|
| 262 | } | 
|---|
| 263 | function TCCOWRPCBroker.WasUserDefined: Boolean; | 
|---|
| 264 | begin | 
|---|
| 265 | Result := FWasUserDefined; | 
|---|
| 266 | end; | 
|---|
| 267 |  | 
|---|
| 268 | function TCCOWRPCBroker.IsUserCleared: Boolean; | 
|---|
| 269 | var | 
|---|
| 270 | CCOWcontextItem: IContextItemCollection;      //CCOW | 
|---|
| 271 | CCOWdataItem1: IContextItem;                  //CCOW | 
|---|
| 272 | Name: String; | 
|---|
| 273 | begin | 
|---|
| 274 | Result := False; | 
|---|
| 275 | Name := CCOW_LOGON_ID; | 
|---|
| 276 | if (Contextor <> nil) then | 
|---|
| 277 | try | 
|---|
| 278 | //See if context contains the ID item | 
|---|
| 279 | CCOWcontextItem := Contextor.CurrentContext; | 
|---|
| 280 | CCOWDataItem1 := CCowContextItem.Present(Name); | 
|---|
| 281 | if (CCOWdataItem1 <> nil) then    //1 | 
|---|
| 282 | begin | 
|---|
| 283 | If CCOWdataItem1.Value = '' then | 
|---|
| 284 | Result := True | 
|---|
| 285 | else | 
|---|
| 286 | FWasUserDefined := True; | 
|---|
| 287 | end | 
|---|
| 288 | else | 
|---|
| 289 | Result := True; | 
|---|
| 290 | finally | 
|---|
| 291 | end; //try | 
|---|
| 292 | end; | 
|---|
| 293 |  | 
|---|
| 294 | {------------------------ AuthenticateUser ------------------------ | 
|---|
| 295 | ------------------------------------------------------------------} | 
|---|
| 296 | procedure AuthenticateUser(ConnectingBroker: TCCOWRPCBroker); | 
|---|
| 297 | var | 
|---|
| 298 | SaveClearParmeters, SaveClearResults: boolean; | 
|---|
| 299 | SaveParam: TParams; | 
|---|
| 300 | SaveRemoteProcedure, SaveRpcVersion: string; | 
|---|
| 301 | SaveResults: TStrings; | 
|---|
| 302 | blnSignedOn: boolean; | 
|---|
| 303 | SaveKernelLogin: boolean; | 
|---|
| 304 | SaveVistaLogin: TVistaLogin; | 
|---|
| 305 | OldExceptionHandler: TExceptionEvent; | 
|---|
| 306 | OldHandle: THandle; | 
|---|
| 307 | begin | 
|---|
| 308 | With ConnectingBroker do | 
|---|
| 309 | begin | 
|---|
| 310 | SaveParam := TParams.Create(nil); | 
|---|
| 311 | SaveParam.Assign(Param);                  //save off settings | 
|---|
| 312 | SaveRemoteProcedure := RemoteProcedure; | 
|---|
| 313 | SaveRpcVersion := RpcVersion; | 
|---|
| 314 | SaveResults := Results; | 
|---|
| 315 | SaveClearParmeters := ClearParameters; | 
|---|
| 316 | SaveClearResults := ClearResults; | 
|---|
| 317 | ClearParameters := True;                  //set'em as I need'em | 
|---|
| 318 | ClearResults := True; | 
|---|
| 319 | SaveKernelLogin := KernelLogin;     //  p13 | 
|---|
| 320 | SaveVistaLogin := Login;            //  p13 | 
|---|
| 321 | end; | 
|---|
| 322 |  | 
|---|
| 323 | blnSignedOn := False;                       //initialize to bad sign-on | 
|---|
| 324 |  | 
|---|
| 325 | if ConnectingBroker.AccessVerifyCodes <> '' then   // p13 handle as AVCode single signon | 
|---|
| 326 | begin | 
|---|
| 327 | ConnectingBroker.Login.AccessCode := Piece(ConnectingBroker.AccessVerifyCodes, ';', 1); | 
|---|
| 328 | ConnectingBroker.Login.VerifyCode := Piece(ConnectingBroker.AccessVerifyCodes, ';', 2); | 
|---|
| 329 | ConnectingBroker.Login.Mode := lmAVCodes; | 
|---|
| 330 | ConnectingBroker.KernelLogIn := False; | 
|---|
| 331 | end; | 
|---|
| 332 |  | 
|---|
| 333 | //CCOW start | 
|---|
| 334 | if ConnectingBroker.KernelLogIn and (not (ConnectingBroker.Contextor = nil)) then | 
|---|
| 335 | begin | 
|---|
| 336 | CCOWtoken := ConnectingBroker.GetCCOWtoken(ConnectingBroker.Contextor); | 
|---|
| 337 | if length(CCOWtoken)>0 then | 
|---|
| 338 | begin | 
|---|
| 339 | ConnectingBroker.FKernelLogIn := false; | 
|---|
| 340 | ConnectingBroker.Login.Mode := lmAppHandle; | 
|---|
| 341 | ConnectingBroker.Login.LogInHandle := CCOWtoken; | 
|---|
| 342 | end; | 
|---|
| 343 | end; | 
|---|
| 344 | //CCOW end | 
|---|
| 345 | //CCOW Start                                // p13  following section for silent signon | 
|---|
| 346 | if not ConnectingBroker.FKernelLogIn then | 
|---|
| 347 | if ConnectingBroker.FLogin <> nil then     //the user.  vistalogin contains login info | 
|---|
| 348 | begin | 
|---|
| 349 | blnsignedon := SilentLogin(ConnectingBroker);    // RpcSLogin unit | 
|---|
| 350 | if not blnSignedOn then | 
|---|
| 351 | begin     //Switch back to Kernel Login | 
|---|
| 352 | ConnectingBroker.FKernelLogIn := true; | 
|---|
| 353 | ConnectingBroker.Login.Mode := lmAVCodes; | 
|---|
| 354 | end; | 
|---|
| 355 | end; | 
|---|
| 356 | //CCOW end | 
|---|
| 357 |  | 
|---|
| 358 | if ConnectingBroker.FKernelLogIn then | 
|---|
| 359 | begin   //p13 | 
|---|
| 360 | CCOWToken := '';  //  061201 JLI if can't sign on with Token clear it so can get new one | 
|---|
| 361 | if Assigned(Application.OnException) then | 
|---|
| 362 | OldExceptionHandler := Application.OnException | 
|---|
| 363 | else | 
|---|
| 364 | OldExceptionHandler := nil; | 
|---|
| 365 | Application.OnException := TfrmErrMsg.RPCBShowException; | 
|---|
| 366 | frmSignon := TfrmSignon.Create(Application); | 
|---|
| 367 | try | 
|---|
| 368 |  | 
|---|
| 369 | //    ShowApplicationAndFocusOK(Application); | 
|---|
| 370 | OldHandle := GetForegroundWindow; | 
|---|
| 371 | SetForegroundWindow(frmSignon.Handle); | 
|---|
| 372 | PrepareSignonForm(ConnectingBroker); | 
|---|
| 373 | if SetUpSignOn then                       //SetUpSignOn in loginfrm unit. | 
|---|
| 374 | begin                                     //True if signon needed | 
|---|
| 375 |  | 
|---|
| 376 | if frmSignOn.lblServer.Caption <> '' then | 
|---|
| 377 | begin | 
|---|
| 378 | frmSignOn.ShowModal;                    //do interactive logon   // p13 | 
|---|
| 379 | if frmSignOn.Tag = 1 then               //Tag=1 for good logon | 
|---|
| 380 | blnSignedOn := True;                   //Successfull logon | 
|---|
| 381 | end | 
|---|
| 382 | end | 
|---|
| 383 | else                                      //False when no logon needed | 
|---|
| 384 | blnSignedOn := NoSignOnNeeded;          //Returns True always (for now!) | 
|---|
| 385 | if blnSignedOn then                       //P6 If logged on, retrieve user info. | 
|---|
| 386 | begin | 
|---|
| 387 | GetBrokerInfo(ConnectingBroker); | 
|---|
| 388 | if not SelDiv.ChooseDiv('',ConnectingBroker) then | 
|---|
| 389 | begin | 
|---|
| 390 | blnSignedOn := False;//P8 | 
|---|
| 391 | {Select division if multi-division user.  First parameter is 'userid' | 
|---|
| 392 | (DUZ or username) for future use. (P8)} | 
|---|
| 393 | ConnectingBroker.Login.ErrorText := 'Failed to select Division';  // p13 set some text indicating problem | 
|---|
| 394 | end; | 
|---|
| 395 | end; | 
|---|
| 396 | SetForegroundWindow(OldHandle); | 
|---|
| 397 | finally | 
|---|
| 398 | frmSignon.Free; | 
|---|
| 399 | //      frmSignon.Release;                        //get rid of signon form | 
|---|
| 400 |  | 
|---|
| 401 | //      if ConnectingBroker.Owner is TForm then | 
|---|
| 402 | //        SetForegroundWindow(TForm(ConnectingBroker.Owner).Handle) | 
|---|
| 403 | //      else | 
|---|
| 404 | //        SetForegroundWindow(ActiveWindow); | 
|---|
| 405 | ShowApplicationAndFocusOK(Application); | 
|---|
| 406 | end ; //try | 
|---|
| 407 | if Assigned(OldExceptionHandler) then | 
|---|
| 408 | Application.OnException := OldExceptionHandler; | 
|---|
| 409 | end;   //if kernellogin | 
|---|
| 410 | // p13  following section for silent signon | 
|---|
| 411 | if (not ConnectingBroker.KernelLogIn) and (not blnsignedon) then     // was doing the signon twice if already true | 
|---|
| 412 | if ConnectingBroker.Login <> nil then     //the user.  vistalogin contains login info | 
|---|
| 413 | blnsignedon := SilentLogin(ConnectingBroker);    // RpcSLogin unit | 
|---|
| 414 | if not blnsignedon then | 
|---|
| 415 | begin | 
|---|
| 416 | //    ConnectingBroker.Login.FailedLogin(ConnectingBroker.Login); | 
|---|
| 417 | TXWBWinsock(ConnectingBroker.XWBWinsock).NetworkDisconnect(ConnectingBroker.Socket); | 
|---|
| 418 | end | 
|---|
| 419 | else | 
|---|
| 420 | GetBrokerInfo(ConnectingBroker); | 
|---|
| 421 |  | 
|---|
| 422 | //reset the Broker | 
|---|
| 423 | with ConnectingBroker do | 
|---|
| 424 | begin | 
|---|
| 425 | ClearParameters := SaveClearParmeters; | 
|---|
| 426 | ClearResults := SaveClearResults; | 
|---|
| 427 | Param.Assign(SaveParam);                  //restore settings | 
|---|
| 428 | SaveParam.Free; | 
|---|
| 429 | RemoteProcedure := SaveRemoteProcedure; | 
|---|
| 430 | RpcVersion := SaveRpcVersion; | 
|---|
| 431 | Results := SaveResults; | 
|---|
| 432 | FKernelLogin := SaveKernelLogin;         // p13 | 
|---|
| 433 | FLogin := SaveVistaLogin;                // p13 | 
|---|
| 434 | end; | 
|---|
| 435 |  | 
|---|
| 436 | if not blnSignedOn then                     //Flag for unsuccessful signon. | 
|---|
| 437 | TXWBWinsock(ConnectingBroker.XWBWinsock).NetError('',XWB_BadSignOn);               //Will raise error. | 
|---|
| 438 |  | 
|---|
| 439 | end; | 
|---|
| 440 |  | 
|---|
| 441 | {----------------------- GetCCOWHandle -------------------------- | 
|---|
| 442 | Private function to return a special CCOW Handle from the server | 
|---|
| 443 | which is set into the CCOW context. | 
|---|
| 444 | The Broker of a new application can get the CCOWHandle from the context | 
|---|
| 445 | and use it to do a ImAPPHandle Sign-on. | 
|---|
| 446 | ----------------------------------------------------------------} | 
|---|
| 447 | function  TCCOWRPCBroker.GetCCOWHandle(ConnectedBroker : TCCOWRPCBroker): String;   // p13 | 
|---|
| 448 | begin | 
|---|
| 449 | Result := ''; | 
|---|
| 450 | with ConnectedBroker do | 
|---|
| 451 | try                          // to permit it to work correctly if CCOW is not installed on the server. | 
|---|
| 452 | begin | 
|---|
| 453 | RemoteProcedure := 'XUS GET CCOW TOKEN'; | 
|---|
| 454 | Call; | 
|---|
| 455 | Result := Results[0]; | 
|---|
| 456 | Domain := Results[1]; | 
|---|
| 457 | RemoteProcedure := 'XUS CCOW VAULT PARAM'; | 
|---|
| 458 | Call; | 
|---|
| 459 | PassCode1 := Results[0]; | 
|---|
| 460 | PassCode2 := Results[1]; | 
|---|
| 461 | end; | 
|---|
| 462 | except | 
|---|
| 463 | Result := ''; | 
|---|
| 464 | end; | 
|---|
| 465 | end; | 
|---|
| 466 |  | 
|---|
| 467 | //CCOW start | 
|---|
| 468 | procedure TCCOWRPCBroker.CCOWsetUser(Uname, token, Domain, Vpid: string; Contextor: | 
|---|
| 469 | TContextorControl); | 
|---|
| 470 | var | 
|---|
| 471 | CCOWdata: IContextItemCollection;             //CCOW | 
|---|
| 472 | CCOWdataItem1,CCOWdataItem2,CCOWdataItem3: IContextItem; | 
|---|
| 473 | CCOWdataItem4,CCOWdataItem5: IContextItem;    //CCOW | 
|---|
| 474 | Cname: string; | 
|---|
| 475 | begin | 
|---|
| 476 | if Contextor <> nil then | 
|---|
| 477 | begin | 
|---|
| 478 | try | 
|---|
| 479 | //Part 1 | 
|---|
| 480 | Contextor.StartContextChange; | 
|---|
| 481 | //Part 2 Set the new proposed context data | 
|---|
| 482 | CCOWdata := CoContextItemCollection.Create; | 
|---|
| 483 | CCOWdataItem1 := CoContextItem.Create; | 
|---|
| 484 | Cname := CCOW_LOGON_ID; | 
|---|
| 485 | CCOWdataItem1.Name := Cname; | 
|---|
| 486 | CCOWdataItem1.Value := domain; | 
|---|
| 487 | CCOWData.Add(CCOWdataItem1); | 
|---|
| 488 | CCOWdataItem2 := CoContextItem.Create; | 
|---|
| 489 | Cname := CCOW_LOGON_TOKEN; | 
|---|
| 490 | CCOWdataItem2.Name := Cname; | 
|---|
| 491 | CCOWdataItem2.Value := token; | 
|---|
| 492 | CCOWdata.Add(CCOWdataItem2); | 
|---|
| 493 | CCOWdataItem3 := CoContextItem.Create; | 
|---|
| 494 | Cname := CCOW_LOGON_NAME; | 
|---|
| 495 | CCOWdataItem3.Name := Cname; | 
|---|
| 496 | CCOWdataItem3.Value := Uname; | 
|---|
| 497 | CCOWdata.Add(CCOWdataItem3); | 
|---|
| 498 | // | 
|---|
| 499 | CCOWdataItem4 := CoContextItem.Create; | 
|---|
| 500 | Cname := CCOW_LOGON_VPID; | 
|---|
| 501 | CCOWdataItem4.Name := Cname; | 
|---|
| 502 | CCOWdataItem4.Value := Vpid; | 
|---|
| 503 | CCOWdata.Add(CCOWdataItem4); | 
|---|
| 504 | // | 
|---|
| 505 | CCOWdataItem5 := CoContextItem.Create; | 
|---|
| 506 | Cname := CCOW_USER_NAME; | 
|---|
| 507 | CCOWdataItem5.Name := Cname; | 
|---|
| 508 | CCOWdataItem5.Value := Uname; | 
|---|
| 509 | CCOWdata.Add(CCOWdataItem5); | 
|---|
| 510 | //Part 3 Make change | 
|---|
| 511 | Contextor.EndContextChange(true, CCOWdata); | 
|---|
| 512 | //We don't need to check CCOWresponce | 
|---|
| 513 | finally | 
|---|
| 514 | end;  //try | 
|---|
| 515 | end; //if | 
|---|
| 516 | end; | 
|---|
| 517 |  | 
|---|
| 518 | //Get Token from CCOW context | 
|---|
| 519 | function TCCOWRPCBroker.GetCCOWtoken(Contextor: TContextorControl): string; | 
|---|
| 520 | var | 
|---|
| 521 | CCOWdataItem1: IContextItem;                 //CCOW | 
|---|
| 522 | CCOWcontextItem: IContextItemCollection;      //CCOW | 
|---|
| 523 | name: string; | 
|---|
| 524 | begin | 
|---|
| 525 | result := ''; | 
|---|
| 526 | name := CCOW_LOGON_TOKEN; | 
|---|
| 527 | if (Contextor <> nil) then | 
|---|
| 528 | try | 
|---|
| 529 | CCOWcontextItem := Contextor.CurrentContext; | 
|---|
| 530 | //See if context contains the ID item | 
|---|
| 531 | CCOWdataItem1 := CCOWcontextItem.Present(name); | 
|---|
| 532 | if (CCOWdataItem1 <> nil) then    //1 | 
|---|
| 533 | begin | 
|---|
| 534 | result := CCOWdataItem1.Value; | 
|---|
| 535 | if not (result = '') then | 
|---|
| 536 | FWasUserDefined := True; | 
|---|
| 537 | end; | 
|---|
| 538 | FCCOWLogonIDName := CCOW_LOGON_ID; | 
|---|
| 539 | FCCOWLogonName := CCOW_LOGON_NAME; | 
|---|
| 540 | FCCOWLogonVpid := CCOW_LOGON_VPID; | 
|---|
| 541 | CCOWdataItem1 := CCOWcontextItem.Present(CCOW_LOGON_ID); | 
|---|
| 542 | if CCOWdataItem1 <> nil then | 
|---|
| 543 | FCCOWLogonIdValue := CCOWdataItem1.Value; | 
|---|
| 544 | CCOWdataItem1 := CCOWcontextItem.Present(CCOW_LOGON_NAME); | 
|---|
| 545 | if CCOWdataItem1 <> nil then | 
|---|
| 546 | FCCOWLogonNameValue := CCOWdataItem1.Value; | 
|---|
| 547 | CCOWdataItem1 := CCOWcontextItem.Present(CCOW_LOGON_VPID); | 
|---|
| 548 | if CCOWdataItem1 <> nil then | 
|---|
| 549 | FCCOWLogonVpidValue := CCOWdataItem1.Value; | 
|---|
| 550 | finally | 
|---|
| 551 | end; //try | 
|---|
| 552 | end; | 
|---|
| 553 |  | 
|---|
| 554 | //Get Name from CCOW context | 
|---|
| 555 | function TCCOWRPCBroker.GetCCOWduz(Contextor: TContextorControl): string; | 
|---|
| 556 | var | 
|---|
| 557 | CCOWdataItem1: IContextItem;                  //CCOW | 
|---|
| 558 | CCOWcontextItem: IContextItemCollection;      //CCOW | 
|---|
| 559 | name: string; | 
|---|
| 560 | begin | 
|---|
| 561 | result := ''; | 
|---|
| 562 | name := CCOW_LOGON_ID; | 
|---|
| 563 | if (Contextor <> nil) then | 
|---|
| 564 | try | 
|---|
| 565 | CCOWcontextItem := Contextor.CurrentContext; | 
|---|
| 566 | //See if context contains the ID item | 
|---|
| 567 | CCOWdataItem1 := CCOWcontextItem.Present(name); | 
|---|
| 568 | if (CCOWdataItem1 <> nil) then    //1 | 
|---|
| 569 | begin | 
|---|
| 570 | result := CCOWdataItem1.Value; | 
|---|
| 571 | if result <> '' then | 
|---|
| 572 | FWasUserDefined := True; | 
|---|
| 573 | end; | 
|---|
| 574 | finally | 
|---|
| 575 | end; //try | 
|---|
| 576 | end; | 
|---|
| 577 |  | 
|---|
| 578 | function TCCOWRPCBroker.IsUserContextPending(aContextItemCollection: | 
|---|
| 579 | IContextItemCollection): Boolean; | 
|---|
| 580 | var | 
|---|
| 581 | CCOWdataItem1: IContextItem;                  //CCOW | 
|---|
| 582 | Val1: String; | 
|---|
| 583 | begin | 
|---|
| 584 | result := false; | 
|---|
| 585 | if WasUserDefined() then // indicates data was defined | 
|---|
| 586 | begin | 
|---|
| 587 | Val1 := '';  // look for any USER Context items defined | 
|---|
| 588 | result := True; | 
|---|
| 589 | // | 
|---|
| 590 | CCOWdataItem1 := aContextItemCollection.Present(CCOW_LOGON_ID); | 
|---|
| 591 | if CCOWdataItem1 <> nil then | 
|---|
| 592 | if not (CCOWdataItem1.Value = FCCOWLogonIDValue) then | 
|---|
| 593 | Val1 := '^' + CCOWdataItem1.Value; | 
|---|
| 594 | // | 
|---|
| 595 | CCOWdataItem1 := aContextItemCollection.Present(CCOW_LOGON_NAME); | 
|---|
| 596 | if CCOWdataItem1 <> nil then | 
|---|
| 597 | if not (CCOWdataItem1.Value = FCCOWLogonNameValue) then | 
|---|
| 598 | Val1 := Val1 + '^' + CCOWdataItem1.Value; | 
|---|
| 599 | // | 
|---|
| 600 | CCOWdataItem1 := aContextItemCollection.Present(CCOW_LOGON_VPID); | 
|---|
| 601 | if CCOWdataItem1 <> nil then | 
|---|
| 602 | if not (CCOWdataItem1.Value = FCCOWLogonVpidValue) then | 
|---|
| 603 | Val1 := Val1 + '^' + CCOWdataItem1.Value; | 
|---|
| 604 | // | 
|---|
| 605 | CCOWdataItem1 := aContextItemCollection.Present(CCOW_USER_NAME); | 
|---|
| 606 | if CCOWdataItem1 <> nil then | 
|---|
| 607 | if not (CCOWdataItem1.Value = user.Name) then | 
|---|
| 608 | Val1 := Val1 + '^' + CCOWdataItem1.Value; | 
|---|
| 609 | // | 
|---|
| 610 | if Val1 = '' then    // nothing defined or all matches, so not user context change | 
|---|
| 611 | result := False; | 
|---|
| 612 | end; | 
|---|
| 613 | end; | 
|---|
| 614 |  | 
|---|
| 615 | end. | 
|---|
| 616 |  | 
|---|