Commit 1f42d222b4e44c736b2407efebe3e81307aed2e3
1 parent
412c6e1f
Exists in
master
-Modificado função para pegar o usuário logado para consulta pelo WMI;
-Modificada função para filtrar o resultado da consulta LDAP; -Modificado timeout ao LDAP; -Modificado local de estrita do col_patr_exe para Configs;
Showing
3 changed files
with
139 additions
and
111 deletions
Show diff stats
MapaTesteProj/MapaTeste.dcu
No preview for this file type
MapaTesteProj/MapaTeste.dfm
@@ -5,6 +5,7 @@ object frmMapaCacic: TfrmMapaCacic | @@ -5,6 +5,7 @@ object frmMapaCacic: TfrmMapaCacic | ||
5 | ClientHeight = 448 | 5 | ClientHeight = 448 |
6 | ClientWidth = 789 | 6 | ClientWidth = 789 |
7 | Color = clBtnFace | 7 | Color = clBtnFace |
8 | + TransparentColorValue = clBtnFace | ||
8 | Font.Charset = DEFAULT_CHARSET | 9 | Font.Charset = DEFAULT_CHARSET |
9 | Font.Color = clWindowText | 10 | Font.Color = clWindowText |
10 | Font.Height = -11 | 11 | Font.Height = -11 |
@@ -87,6 +88,7 @@ object frmMapaCacic: TfrmMapaCacic | @@ -87,6 +88,7 @@ object frmMapaCacic: TfrmMapaCacic | ||
87 | OnActivate = FormActivate | 88 | OnActivate = FormActivate |
88 | OnClose = FormClose | 89 | OnClose = FormClose |
89 | OnCreate = FormCreate | 90 | OnCreate = FormCreate |
91 | + OnKeyDown = FormKeyDown | ||
90 | DesignSize = ( | 92 | DesignSize = ( |
91 | 789 | 93 | 789 |
92 | 448) | 94 | 448) |
MapaTesteProj/MapaTeste.pas
@@ -32,6 +32,7 @@ uses | @@ -32,6 +32,7 @@ uses | ||
32 | Dialogs, | 32 | Dialogs, |
33 | CACIC_Library, | 33 | CACIC_Library, |
34 | CACIC_Comm, | 34 | CACIC_Comm, |
35 | + CACIC_WMI, | ||
35 | ComCtrls, | 36 | ComCtrls, |
36 | Commctrl, | 37 | Commctrl, |
37 | ShellAPI, | 38 | ShellAPI, |
@@ -60,6 +61,7 @@ var strCollectsPatrimonioLast, | @@ -60,6 +61,7 @@ var strCollectsPatrimonioLast, | ||
60 | Fechar : boolean; | 61 | Fechar : boolean; |
61 | Dummy : integer; | 62 | Dummy : integer; |
62 | OldValue : LongBool; | 63 | OldValue : LongBool; |
64 | + formSecondMonitor : TForm; | ||
63 | 65 | ||
64 | type | 66 | type |
65 | TfrmMapaCacic = class(TForm) | 67 | TfrmMapaCacic = class(TForm) |
@@ -104,14 +106,14 @@ type | @@ -104,14 +106,14 @@ type | ||
104 | procedure rdConcordaTermosClick(Sender: TObject); | 106 | procedure rdConcordaTermosClick(Sender: TObject); |
105 | procedure EstadoBarraTarefa(EstadoBarra: Boolean); | 107 | procedure EstadoBarraTarefa(EstadoBarra: Boolean); |
106 | 108 | ||
107 | - function getLastValue(S : String; separador : string): string; | 109 | + function getLastValue(S : String; separador, separador2 : string): string; |
108 | function LDAPName: string; | 110 | function LDAPName: string; |
109 | function NomeComputador : String; | 111 | function NomeComputador : String; |
110 | - function getUserLogon : String; | ||
111 | function getConfigs : String; | 112 | function getConfigs : String; |
112 | function SetCpfUser : String; | 113 | function SetCpfUser : String; |
113 | function SetPatrimonioPC : String; | 114 | function SetPatrimonioPC : String; |
114 | function FormatarCpf(strCpfUser : String) : String; | 115 | function FormatarCpf(strCpfUser : String) : String; |
116 | + procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); | ||
115 | 117 | ||
116 | 118 | ||
117 | private | 119 | private |
@@ -122,7 +124,7 @@ type | @@ -122,7 +124,7 @@ type | ||
122 | strTeInfoPatrimonio5, | 124 | strTeInfoPatrimonio5, |
123 | strTeInfoPatrimonio6, | 125 | strTeInfoPatrimonio6, |
124 | strTeInfoPatrimonio7 : String; | 126 | strTeInfoPatrimonio7 : String; |
125 | - formMonitor: TForm; | 127 | + psswd : String; |
126 | 128 | ||
127 | procedure FormSetFocus(VerificaFoco: Boolean); | 129 | procedure FormSetFocus(VerificaFoco: Boolean); |
128 | procedure MontaInterface; | 130 | procedure MontaInterface; |
@@ -139,6 +141,8 @@ type | @@ -139,6 +141,8 @@ type | ||
139 | 141 | ||
140 | end; | 142 | end; |
141 | 143 | ||
144 | +const SENHA = 'uuddlrlrab'; | ||
145 | + | ||
142 | var frmMapaCacic: TfrmMapaCacic; | 146 | var frmMapaCacic: TfrmMapaCacic; |
143 | 147 | ||
144 | implementation | 148 | implementation |
@@ -184,23 +188,6 @@ begin | @@ -184,23 +188,6 @@ begin | ||
184 | end; | 188 | end; |
185 | 189 | ||
186 | //------------------------------------------------------------------------------ | 190 | //------------------------------------------------------------------------------ |
187 | -//------------------FUNÇÃO PARA RETORNAR O NOME DO USUARIO.--------------------- | ||
188 | -//------------------------------------------------------------------------------ | ||
189 | - | ||
190 | -Function TfrmMapaCacic.getUserLogon : String; | ||
191 | -var | ||
192 | - lpBuffer : PChar; | ||
193 | - nSize : DWord; | ||
194 | -const Buff_Size = MAX_COMPUTERNAME_LENGTH + 1; | ||
195 | -begin | ||
196 | - nSize := Buff_Size; | ||
197 | - lpBuffer := StrAlloc(Buff_Size); | ||
198 | - GetUserName(lpBuffer,nSize); | ||
199 | - Result := String(lpBuffer); | ||
200 | - StrDispose(lpBuffer); | ||
201 | -end; | ||
202 | - | ||
203 | -//------------------------------------------------------------------------------ | ||
204 | //----------------------FUNÇÃO PARA RETORNAR O PATRIMONIO----------------------- | 191 | //----------------------FUNÇÃO PARA RETORNAR O PATRIMONIO----------------------- |
205 | //------------------------------------------------------------------------------ | 192 | //------------------------------------------------------------------------------ |
206 | 193 | ||
@@ -246,7 +233,7 @@ var | @@ -246,7 +233,7 @@ var | ||
246 | strUser : String; | 233 | strUser : String; |
247 | begin | 234 | begin |
248 | Result:=''; | 235 | Result:=''; |
249 | - strUser:=getUserLogon; | 236 | + strUser:=strTeInfoPatrimonio3; |
250 | 237 | ||
251 | if (pos('-',strUser) > 0) then | 238 | if (pos('-',strUser) > 0) then |
252 | strCpfUser:=copy(strUser, 0, (pos('-', strUser)-1)); | 239 | strCpfUser:=copy(strUser, 0, (pos('-', strUser)-1)); |
@@ -259,14 +246,17 @@ end; | @@ -259,14 +246,17 @@ end; | ||
259 | //-----------------------APÓS O SEPARADOR SELECIONADO--------------------------- | 246 | //-----------------------APÓS O SEPARADOR SELECIONADO--------------------------- |
260 | //------------------------------------------------------------------------------ | 247 | //------------------------------------------------------------------------------ |
261 | 248 | ||
262 | -function TfrmMapaCacic.getLastValue(S : String; separador : string): string; | 249 | +function TfrmMapaCacic.getLastValue(S : String; separador, separador2 : string): string; |
263 | var | 250 | var |
264 | - conta : integer; // variáveis auxiliares | 251 | + conta, tamanho_separador, tamanho_separador2 : integer; // variáveis auxiliares |
265 | resultado : TStringList; // variáveis auxiliares | 252 | resultado : TStringList; // variáveis auxiliares |
266 | - Saux : string; // variáveis auxiliares | 253 | + Saux, index : string; // variáveis auxiliares |
267 | begin | 254 | begin |
268 | resultado := TStringList.Create; // inicializa variavel | 255 | resultado := TStringList.Create; // inicializa variavel |
269 | - conta := pos(separador,S); // pega posição do separador | 256 | + tamanho_separador:= Length(separador); |
257 | + tamanho_separador2:= Length(separador2); | ||
258 | + index:=copy(separador2, 1, pos(#$D#$A, separador2)-1); | ||
259 | + conta := pos(separador,S)+tamanho_separador; // pega posição do separador | ||
270 | if conta <> 0 then begin // verifica se existe o separador caso contrario trata apenas //como uma única linha | 260 | if conta <> 0 then begin // verifica se existe o separador caso contrario trata apenas //como uma única linha |
271 | while trim(S) <> '' do begin // enquanto S não for nulo executa | 261 | while trim(S) <> '' do begin // enquanto S não for nulo executa |
272 | Saux := copy(S,1,conta-1); // Variável Saux recebe primeiro valor | 262 | Saux := copy(S,1,conta-1); // Variável Saux recebe primeiro valor |
@@ -275,15 +265,21 @@ begin | @@ -275,15 +265,21 @@ begin | ||
275 | Saux := S; | 265 | Saux := S; |
276 | S := ''; | 266 | S := ''; |
277 | end; | 267 | end; |
278 | - resultado.Add(Saux); // adiciona linhas na string lista | ||
279 | - conta := pos(separador,S); //pega posição do separador | 268 | + if pos(separador2, Saux)>0 then begin |
269 | + delete(Saux, 1, tamanho_separador2); | ||
270 | + resultado.values[index]:= | ||
271 | + copy(Saux,1,pos(#$D#$A, Saux)); | ||
272 | + break; | ||
273 | + end; | ||
274 | + resultado.add(Saux); // adiciona linhas na string lista | ||
275 | + conta := pos(separador,S); //pega posição do separador | ||
280 | end; | 276 | end; |
281 | - end | 277 | + end |
282 | else begin | 278 | else begin |
283 | Saux := S; | 279 | Saux := S; |
284 | resultado.Add(Saux); | 280 | resultado.Add(Saux); |
285 | end; | 281 | end; |
286 | - Result := trim(resultado[resultado.count-1]); // retorna resultado como uma lista indexada | 282 | + Result := trim(resultado.values[index]); // retorna resultado como uma lista indexada |
287 | end; | 283 | end; |
288 | 284 | ||
289 | //------------------------------------------------------------------------------ | 285 | //------------------------------------------------------------------------------ |
@@ -395,7 +391,7 @@ if edTeInfoNome.text <> '' then | @@ -395,7 +391,7 @@ if edTeInfoNome.text <> '' then | ||
395 | btGravarInformacoes.Caption := 'Informações enviadas com sucesso...'; | 391 | btGravarInformacoes.Caption := 'Informações enviadas com sucesso...'; |
396 | objCacic.setValueToFile('Collects','col_patr_last' , | 392 | objCacic.setValueToFile('Collects','col_patr_last' , |
397 | objCacic.enCrypt(strColetaAtual), strGerColsInfFileName); | 393 | objCacic.enCrypt(strColetaAtual), strGerColsInfFileName); |
398 | - objCacic.setValueToFile('Collects','col_patr_exe', 's', strGerColsInfFileName); | 394 | + objCacic.setValueToFile('Configs','col_patr_exe', 's', strGerColsInfFileName); |
399 | 395 | ||
400 | End; | 396 | End; |
401 | objCacic.writeDebugLog(#13#10 + 'AtualizaPatrimonio: Dados Enviados ao Servidor!'); | 397 | objCacic.writeDebugLog(#13#10 + 'AtualizaPatrimonio: Dados Enviados ao Servidor!'); |
@@ -415,23 +411,6 @@ var strConfigsPatrimonioInterface, | @@ -415,23 +411,6 @@ var strConfigsPatrimonioInterface, | ||
415 | Begin | 411 | Begin |
416 | btCombosUpdate.Enabled := false; | 412 | btCombosUpdate.Enabled := false; |
417 | 413 | ||
418 | - //-------------------------------NOME USUARIO----------------------------------- | ||
419 | - strNomeLDAP := getLastValue(LDAPName, #$D#$A); | ||
420 | - | ||
421 | - | ||
422 | - if (strNomeLDAP <> '') and (strNomeLDAP <> 'Results: 0') then | ||
423 | - begin | ||
424 | - edTeInfoNome.Text := strNomeLDAP; | ||
425 | - edTeInfoNome.Visible := true; | ||
426 | - lbEtiquetaNome.Visible := true; | ||
427 | - end | ||
428 | - else | ||
429 | - begin | ||
430 | - edTeInfoNome.Visible := true; | ||
431 | - edTeInfoNome.Enabled := true; | ||
432 | - lbEtiquetaNome.Visible := true; | ||
433 | - end; | ||
434 | - | ||
435 | //- ----------------------NOME DO COMPUTADOR PARA O EDTEXT----------------------- | 414 | //- ----------------------NOME DO COMPUTADOR PARA O EDTEXT----------------------- |
436 | edTeInfoNomeComputador.Text := NomeComputador; | 415 | edTeInfoNomeComputador.Text := NomeComputador; |
437 | if edTeInfoNomeComputador.Text <> '' then | 416 | if edTeInfoNomeComputador.Text <> '' then |
@@ -444,13 +423,33 @@ Begin | @@ -444,13 +423,33 @@ Begin | ||
444 | 423 | ||
445 | //-----------------------------USUARIO LOGADO----------------------------------- | 424 | //-----------------------------USUARIO LOGADO----------------------------------- |
446 | 425 | ||
447 | - edTeInfoUserLogado.Text := getUserLogon; | 426 | +// edTeInfoUserLogado.Text := getUserLogon; |
427 | + strTeInfoPatrimonio3:=objCACIC.getValueFromTags('UserName',fetchWMIvalues('Win32_ComputerSystem',objCACIC.getLocalFolderName,'UserName')); | ||
428 | + strTeInfoPatrimonio3:=copy(strTeInfoPatrimonio3, pos('\', strTeInfoPatrimonio3)+1, length(strTeInfoPatrimonio3)); | ||
429 | + edTeInfoUserLogado.Text:=strTeInfoPatrimonio3; | ||
448 | if edTeInfoUserLogado.Text <> '' then | 430 | if edTeInfoUserLogado.Text <> '' then |
449 | begin | 431 | begin |
450 | lbEtiquetaUserLogado.Visible := true; | 432 | lbEtiquetaUserLogado.Visible := true; |
451 | edTeInfoUserLogado.Visible := true; | 433 | edTeInfoUserLogado.Visible := true; |
452 | end; | 434 | end; |
453 | 435 | ||
436 | + //-------------------------------NOME USUARIO----------------------------------- | ||
437 | + strNomeLDAP := getLastValue(LDAPName, 'Attribute:', 'cn'+#$D#$A); | ||
438 | + | ||
439 | + | ||
440 | + if (strNomeLDAP <> '') and (strNomeLDAP <> 'Results: 0') then | ||
441 | + begin | ||
442 | + edTeInfoNome.Text := strNomeLDAP; | ||
443 | + edTeInfoNome.Visible := true; | ||
444 | + lbEtiquetaNome.Visible := true; | ||
445 | + end | ||
446 | + else | ||
447 | + begin | ||
448 | + edTeInfoNome.Visible := true; | ||
449 | + edTeInfoNome.Enabled := true; | ||
450 | + lbEtiquetaNome.Visible := true; | ||
451 | + end; | ||
452 | + | ||
454 | //-------------------------------CPF USUARIO------------------------------------ | 453 | //-------------------------------CPF USUARIO------------------------------------ |
455 | 454 | ||
456 | { edTeInfoCpfUser.Text := FormatarCpf(SetCpfUser); | 455 | { edTeInfoCpfUser.Text := FormatarCpf(SetCpfUser); |
@@ -522,7 +521,7 @@ begin | @@ -522,7 +521,7 @@ begin | ||
522 | Else | 521 | Else |
523 | begin | 522 | begin |
524 | Action := caFree; | 523 | Action := caFree; |
525 | - formMonitor:=nil; | 524 | + formSecondMonitor:=nil; |
526 | objCacic.writeDebugLog('FormClose: ' + Sender.ClassName); | 525 | objCacic.writeDebugLog('FormClose: ' + Sender.ClassName); |
527 | Finalizar(true); | 526 | Finalizar(true); |
528 | end; | 527 | end; |
@@ -538,7 +537,7 @@ begin | @@ -538,7 +537,7 @@ begin | ||
538 | on E:Exception do | 537 | on E:Exception do |
539 | Begin | 538 | Begin |
540 | MessageDlg(#13#13+'Problemas ao gerar formulário.',mtError, [mbOK], 0); | 539 | MessageDlg(#13#13+'Problemas ao gerar formulário.',mtError, [mbOK], 0); |
541 | - EstadoBarraTarefa(TRUE); | 540 | +// EstadoBarraTarefa(TRUE); |
542 | objCacic.writeExceptionLog(E.Message,e.ClassName); | 541 | objCacic.writeExceptionLog(E.Message,e.ClassName); |
543 | Sair; | 542 | Sair; |
544 | End; | 543 | End; |
@@ -550,8 +549,8 @@ var | @@ -550,8 +549,8 @@ var | ||
550 | foco: boolean; | 549 | foco: boolean; |
551 | 550 | ||
552 | begin | 551 | begin |
553 | - | ||
554 | - | 552 | + psswd := ''; |
553 | + KeyPreview := true; | ||
555 | frmMapaCacic.boolAcessoOK := true; | 554 | frmMapaCacic.boolAcessoOK := true; |
556 | //Definido TRUE, se não, mesmo que o foco seja falso, a aplicação não é fechada quando quiser. | 555 | //Definido TRUE, se não, mesmo que o foco seja falso, a aplicação não é fechada quando quiser. |
557 | Fechar:=TRUE; | 556 | Fechar:=TRUE; |
@@ -621,7 +620,7 @@ begin | @@ -621,7 +620,7 @@ begin | ||
621 | pnMessageBox.Visible := false; | 620 | pnMessageBox.Visible := false; |
622 | objCacic.writeDebugLog('FormActivate: Requisitando informações de patrimônio da estação...'); | 621 | objCacic.writeDebugLog('FormActivate: Requisitando informações de patrimônio da estação...'); |
623 | 622 | ||
624 | - if (getConfigs <> '0') then | 623 | + if getConfigs <> '0' then |
625 | begin | 624 | begin |
626 | mapa; | 625 | mapa; |
627 | FormSetFocus(foco) | 626 | FormSetFocus(foco) |
@@ -648,13 +647,13 @@ begin | @@ -648,13 +647,13 @@ begin | ||
648 | End; | 647 | End; |
649 | end; | 648 | end; |
650 | 649 | ||
650 | + | ||
651 | procedure TfrmMapaCacic.FormActivate(Sender: TObject); | 651 | procedure TfrmMapaCacic.FormActivate(Sender: TObject); |
652 | -var strNomeLDAP: String; | ||
653 | 652 | ||
654 | begin | 653 | begin |
655 | pnVersao.Caption := 'Versão: ' + objCacic.getVersionInfo(ParamStr(0)); | 654 | pnVersao.Caption := 'Versão: ' + objCacic.getVersionInfo(ParamStr(0)); |
656 | strFrmAtual := 'Principal'; | 655 | strFrmAtual := 'Principal'; |
657 | - | 656 | + |
658 | end; | 657 | end; |
659 | 658 | ||
660 | procedure TfrmMapaCacic.btCombosUpdateClick(Sender: TObject); | 659 | procedure TfrmMapaCacic.btCombosUpdateClick(Sender: TObject); |
@@ -672,9 +671,7 @@ end; | @@ -672,9 +671,7 @@ end; | ||
672 | procedure TfrmMapaCacic.FormSetFocus(VerificaFoco: Boolean); | 671 | procedure TfrmMapaCacic.FormSetFocus(VerificaFoco: Boolean); |
673 | var | 672 | var |
674 | r : TRect; | 673 | r : TRect; |
675 | - MonInfo: TMonitorInfoEx; | ||
676 | - DispDev : TDisplayDevice; | ||
677 | - i, monitorWidth, monitorHeight: Integer; | 674 | + H : HWnd; |
678 | begin | 675 | begin |
679 | if VerificaFoco then | 676 | if VerificaFoco then |
680 | begin | 677 | begin |
@@ -689,31 +686,56 @@ begin | @@ -689,31 +686,56 @@ begin | ||
689 | Screen.WorkAreaRect; | 686 | Screen.WorkAreaRect; |
690 | Top := Screen.WorkAreaTop; | 687 | Top := Screen.WorkAreaTop; |
691 | Left := Screen.WorkAreaLeft; | 688 | Left := Screen.WorkAreaLeft; |
692 | - {if Screen.MonitorCount>1 then | 689 | + Width := Screen.WorkAreaWidth; |
690 | + Height := Screen.Height; | ||
691 | + { if Screen.MonitorCount>1 then | ||
693 | begin | 692 | begin |
694 | - formMonitor := TForm.Create(Application); | 693 | + formSecondMonitor := TForm.Create(nil); |
695 | for i := 0 to Screen.MonitorCount - 1 do | 694 | for i := 0 to Screen.MonitorCount - 1 do |
696 | begin | 695 | begin |
697 | if not Screen.Monitors[i].Primary then | 696 | if not Screen.Monitors[i].Primary then |
698 | - formMonitor.WindowState := wsNormal; | ||
699 | - formMonitor.BorderStyle := bsNone; | ||
700 | - formMonitor.MakeFullyVisible(Screen.Monitors[i]); | ||
701 | - formMonitor.Visible:=true; | 697 | + formSecondMonitor.WindowState := wsNormal; |
698 | + formSecondMonitor.BorderStyle := bsNone; | ||
699 | + formSecondMonitor.Width := Screen.Monitors[i].Width; | ||
700 | + formSecondMonitor.Height := Screen.Monitors[i].Height; | ||
701 | + formSecondMonitor.top := Screen.Monitors[i].top; | ||
702 | + formSecondMonitor.left := Screen.Monitors[i].left; | ||
703 | + formSecondMonitor.Enabled := true; | ||
704 | + formSecondMonitor.Visible:=true; | ||
702 | end; | 705 | end; |
703 | - end | ||
704 | - else | ||
705 | - begin | ||
706 | - monitorWidth := screen.Width; | ||
707 | - monitorHeight:= screen.Height; | ||
708 | - end;} | 706 | + end; |
707 | + } | ||
708 | +// EstadoBarraTarefa(FALSE); | ||
709 | + | ||
710 | + H := FindWindow(Nil,'mapacacic'); {troque project1 pelo nome do seu projeto)} | ||
711 | + if H <> 0 then ShowWindow(H,SW_HIDE); | ||
712 | + | ||
709 | 713 | ||
710 | - Width := Screen.WorkAreaWidth; | ||
711 | - Height := Screen.Height; | ||
712 | - EstadoBarraTarefa(FALSE); | ||
713 | end; | 714 | end; |
714 | 715 | ||
715 | end; | 716 | end; |
716 | 717 | ||
718 | +//CODE PRA FECHAR O MAPA SEM PRESSIONAR NADA. (/\ + /\ + V + V + <- + -> + <- + -> + A + B) | ||
719 | +procedure TfrmMapaCacic.FormKeyDown(Sender: TObject; var Key: Word; | ||
720 | + Shift: TShiftState); | ||
721 | + | ||
722 | +begin | ||
723 | + case Key of | ||
724 | + VK_Left : psswd:=psswd+'l'; | ||
725 | + VK_Right : psswd:=psswd+'r'; | ||
726 | + VK_Up : psswd:=psswd+'u'; | ||
727 | + VK_Down : psswd:=psswd+'d'; | ||
728 | + 65 : psswd:=psswd+'a'; | ||
729 | + 66 : psswd:=psswd+'b'; | ||
730 | + else | ||
731 | + psswd:=''; | ||
732 | + end; | ||
733 | + if psswd = SENHA then | ||
734 | + sair; | ||
735 | + | ||
736 | +end; | ||
737 | + | ||
738 | + | ||
717 | //------------------------------------------------------------------------------ | 739 | //------------------------------------------------------------------------------ |
718 | //----------------ESCONDE BARRA DE TAREFAS-------------------------------------- | 740 | //----------------ESCONDE BARRA DE TAREFAS-------------------------------------- |
719 | //------------------------------------------------------------------------------ | 741 | //------------------------------------------------------------------------------ |
@@ -813,49 +835,53 @@ var | @@ -813,49 +835,53 @@ var | ||
813 | 835 | ||
814 | begin | 836 | begin |
815 | result := ''; | 837 | result := ''; |
816 | - ldap := TLDAPsend.Create; | ||
817 | - retorno := TStringList.Create; | ||
818 | 838 | ||
819 | // PEGANDO OS DADOS DO POR MEIO DO GET/CONFIGS, ONDE SERÁ GRAVADO NO GERCOLS.INF | 839 | // PEGANDO OS DADOS DO POR MEIO DO GET/CONFIGS, ONDE SERÁ GRAVADO NO GERCOLS.INF |
820 | strDadosLDAP := objCacic.deCrypt(objCacic.getValueFromFile('Configs','servidor_autenticacao',strGerColsInfFileName)); | 840 | strDadosLDAP := objCacic.deCrypt(objCacic.getValueFromFile('Configs','servidor_autenticacao',strGerColsInfFileName)); |
821 | - host := objCacic.getValueFromTags('ip', strDadosLDAP); | ||
822 | - username := objCacic.getValueFromTags('usuario', strDadosLDAP); | ||
823 | - psswd := objCacic.getValueFromTags('senha', strDadosLDAP); | ||
824 | - base := objCacic.getValueFromTags('base', strDadosLDAP); | ||
825 | - identificador:= objCacic.getValueFromTags('identificador', strDadosLDAP); | ||
826 | - for i := 0 to 2 do //Até 2 porque são no máxio 3 identificadores que serão passados. | ||
827 | - begin | ||
828 | - aux:=objCacic.getValueFromTags('retorno'+IntToStr(i+1), strDadosLDAP); | ||
829 | - if aux<>'' then | ||
830 | - retorno.Add(aux); | ||
831 | - end; | ||
832 | - if (host<>'') or (base<>'') or (retorno.count=0) then | 841 | + if strDadosLDAP<>'' then |
833 | begin | 842 | begin |
834 | - try | ||
835 | - try | ||
836 | - ldap.TargetHost := host; | ||
837 | - ldap.UserName := username; | ||
838 | - ldap.Password := psswd; | ||
839 | - if ldap.Login then //Loga no LDAP. | ||
840 | - begin | ||
841 | - ldap.BindSasl; //Autentica no LDAP com Usuário e senha repassado. (BindSasl é mais seguro que Bind) | ||
842 | - ldap.Search(base, False, identificador+ '=' + getUserLogon, retorno); //Faz a pesquisa, com o CPF repassado. | ||
843 | - result := LDAPResultdump(ldap.SearchResult); | ||
844 | - ldap.Logout; | ||
845 | - end; | ||
846 | - finally | ||
847 | - ldap.Free; | ||
848 | - retorno.Free; | ||
849 | - end; | ||
850 | - Except | ||
851 | - on E:Exception do | ||
852 | - Begin | ||
853 | - MessageDlg(#13#13+'Problemas para pegar nome do usuário.'+#13#13+ | ||
854 | - 'Por favor, digite seu nome no campo solicitado',mtError, [mbOK], 0); | ||
855 | - objCacic.writeExceptionLog(E.Message,e.ClassName); | ||
856 | - End; | 843 | + ldap := TLDAPsend.Create; |
844 | + retorno := TStringList.Create; | ||
845 | + | ||
846 | + host := objCacic.getValueFromTags('ip', strDadosLDAP); | ||
847 | + username := objCacic.getValueFromTags('usuario', strDadosLDAP); | ||
848 | + psswd := objCacic.getValueFromTags('senha', strDadosLDAP); | ||
849 | + base := objCacic.getValueFromTags('base', strDadosLDAP); | ||
850 | + identificador:= objCacic.getValueFromTags('identificador', strDadosLDAP); | ||
851 | + for i := 0 to 2 do //Até 2 porque são no máxio 3 identificadores que serão passados. | ||
852 | + begin | ||
853 | + aux:=objCacic.getValueFromTags('retorno'+IntToStr(i+1), strDadosLDAP); | ||
854 | + if aux<>'' then | ||
855 | + retorno.Add(aux); | ||
857 | end; | 856 | end; |
858 | - end; | 857 | + if (host<>'') and (base<>'') and (retorno.count<>0) and (username<>'') then |
858 | + begin | ||
859 | + try | ||
860 | + try | ||
861 | + ldap.TargetHost := host; | ||
862 | + ldap.UserName := username; | ||
863 | + ldap.Password := psswd; | ||
864 | + ldap.Timeout := 5000; | ||
865 | + if ldap.Login and ldap.BindSasl then //Loga no LDAP e autentica no LDAP com Usuário e senha repassado. (BindSasl é mais seguro que Bind) | ||
866 | + begin | ||
867 | + ldap.Search(base, False, identificador+ '=' + strTeInfoPatrimonio3, retorno); //Faz a pesquisa, com o CPF repassado. | ||
868 | + result := LDAPResultdump(ldap.SearchResult); | ||
869 | + ldap.Logout; | ||
870 | + end; | ||
871 | + finally | ||
872 | + ldap.Free; | ||
873 | + retorno.Free; | ||
874 | + end; | ||
875 | + Except | ||
876 | + on E:Exception do | ||
877 | + Begin | ||
878 | + MessageDlg(#13#13+'Problemas para pegar nome do usuário.'+#13#13+ | ||
879 | + 'Por favor, digite seu nome no campo solicitado',mtError, [mbOK], 0); | ||
880 | + objCacic.writeExceptionLog(E.Message,e.ClassName); | ||
881 | + End; //on E:Exception do | ||
882 | + end; // Try | ||
883 | + end; // if (host<>'') or (base<>'') or (retorno.count=0) then | ||
884 | + end; //if strDadosLDAP<>'' then | ||
859 | end; | 885 | end; |
860 | 886 | ||
861 | 887 |