Commit 78306c29ad80260a12d26be88f999b3f6672bc5b

Authored by Eric Menezes Noronha
1 parent 3637eed2
Exists in master

-Bug fix.

-Adaptação da função de pesquisa LDAP.
MapaTesteProj/MapaTeste.dcu
No preview for this file type
MapaTesteProj/MapaTeste.pas
... ... @@ -411,42 +411,42 @@ end;
411 411 procedure TfrmMapaCacic.MontaInterface;
412 412 var strConfigsPatrimonioInterface, strNomeLDAP : String;
413 413 Begin
414   - btCombosUpdate.Enabled := false;
  414 + btCombosUpdate.Enabled := false;
415 415  
416 416 //-------------------------------NOME USUARIO-----------------------------------
417   - strNomeLDAP := LDAPName;
  417 + strNomeLDAP := LDAPName;
418 418  
419   - if (strNomeLDAP <> '') and (strNomeLDAP <> 'Results: 0') then
420   - begin
421   - edTeInfoNome.Text := strNomeLDAP;
422   - edTeInfoNome.Visible := true;
423   - lbEtiquetaNome.Visible := true;
424   - end
425   - else
426   - begin
427   - edTeInfoNome.Visible := true;
428   - edTeInfoNome.Enabled := true;
429   - lbEtiquetaNome.Visible := true;
430   - end;
  419 + if (strNomeLDAP <> '') and (strNomeLDAP <> 'Results: 0') then
  420 + begin
  421 + edTeInfoNome.Text := getLastValue(strNomeLDAP, #$D#$A);
  422 + edTeInfoNome.Visible := true;
  423 + lbEtiquetaNome.Visible := true;
  424 + end
  425 + else
  426 + begin
  427 + edTeInfoNome.Visible := true;
  428 + edTeInfoNome.Enabled := true;
  429 + lbEtiquetaNome.Visible := true;
  430 + end;
431 431  
432   -//-----------------------NOME DO COMPUTADOR PARA O EDTEXT-----------------------
433   - edTeInfoNomeComputador.Text := NomeComputador;
434   - if edTeInfoNomeComputador.Text <> '' then
435   - begin
436   - lbEtiquetaNomeComputador.Visible := true;
437   - edTeInfoNomeComputador.Visible := true;
438   - end;
439   - lbEtiquetaNomeComputador.Visible := true;
440   - edTeInfonomeComputador.Visible := true;
  432 +//- ----------------------NOME DO COMPUTADOR PARA O EDTEXT-----------------------
  433 + edTeInfoNomeComputador.Text := NomeComputador;
  434 + if edTeInfoNomeComputador.Text <> '' then
  435 + begin
  436 + lbEtiquetaNomeComputador.Visible := true;
  437 + edTeInfoNomeComputador.Visible := true;
  438 + end;
  439 + lbEtiquetaNomeComputador.Visible := true;
  440 + edTeInfonomeComputador.Visible := true;
441 441  
442 442 //-----------------------------USUARIO LOGADO-----------------------------------
443 443  
444   - edTeInfoUserLogado.Text := getUserLogon;
445   - if edTeInfoUserLogado.Text <> '' then
446   - begin
447   - lbEtiquetaUserLogado.Visible := true;
448   - edTeInfoUserLogado.Visible := true;
449   - end;
  444 + edTeInfoUserLogado.Text := getUserLogon;
  445 + if edTeInfoUserLogado.Text <> '' then
  446 + begin
  447 + lbEtiquetaUserLogado.Visible := true;
  448 + edTeInfoUserLogado.Visible := true;
  449 + end;
450 450  
451 451 //-------------------------------CPF USUARIO------------------------------------
452 452  
... ... @@ -458,12 +458,12 @@ Begin
458 458 end;}
459 459  
460 460 //-----------------------PUXA O IP DA MÁQUINA PARA O EDTEXT-------------------------------------
461   - edTeInfoIpComputador.Text := idipwatch1.LocalIP;
462   - if edTeInfoIpComputador.Text <> '' then
463   - begin
464   - lbEtiquetaIpComputador.Visible := true;
465   - edTeInfoIpComputador.Visible := true;
466   - end;
  461 + edTeInfoIpComputador.Text := idipwatch1.LocalIP;
  462 + if edTeInfoIpComputador.Text <> '' then
  463 + begin
  464 + lbEtiquetaIpComputador.Visible := true;
  465 + edTeInfoIpComputador.Visible := true;
  466 + end;
467 467  
468 468 //-------------------------PATRIMONIO DA MAQUINA--------------------------------
469 469 { edTePatrimonioPc.Text := SetPatrimonioPc;
... ... @@ -472,13 +472,13 @@ Begin
472 472 lbEtiquetaPatrimonioPc.Visible := true;
473 473 edTePatrimonioPc.Visible := true;
474 474 end;}
475   - edTePatrimonioPc.Text := strTeInfoPatrimonio1;
476   - edTePatrimonioPc.Visible := true;
477   - lbEtiquetaPatrimonioPc.Visible := true;
  475 + edTePatrimonioPc.Text := strTeInfoPatrimonio1;
  476 + edTePatrimonioPc.Visible := true;
  477 + lbEtiquetaPatrimonioPc.Visible := true;
478 478  
479 479  
480 480 //----------VALOR DE strGerColsInfFileName ALTERADO PARA ARQUIVO TESTE-----------------------------
481   - strConfigsPatrimonioInterface := objCacic.deCrypt(objCacic.getValueFromFile('Configs','Patrimonio_Interface',strGerColsInfFileName));
  481 + strConfigsPatrimonioInterface := objCacic.deCrypt(objCacic.getValueFromFile('Configs','Patrimonio_Interface',strGerColsInfFileName));
482 482  
483 483 { objCacic.writeDebugLog('MontaInterface: in_exibir_etiqueobjCacic.enCta1 -> "' +
484 484 objCacic.getValueFromTags('in_exibir_etiqueta1',
... ... @@ -539,10 +539,10 @@ Begin
539 539 // if (trim(objCacic.getValueFromTags('in_exibir_etiqueta5', strConfigsPatrimonioInterface)) = 'S') then
540 540 // begin
541 541 //lbEtiqueta5.Caption := objCacic.getValueFromTags('te_etiqueta5', strConfigsPatrimonioInterface);
542   - lbEtiqueta5.Visible := true;
543   - edTeInfoPatrimonio5.Hint := objCacic.getValueFromTags('te_help_etiqueta5', strConfigsPatrimonioInterface);
544   - edTeInfoPatrimonio5.Text := strTeInfoPatrimonio6;
545   - edTeInfoPatrimonio5.visible := True;
  542 + lbEtiqueta5.Visible := true;
  543 + edTeInfoPatrimonio5.Hint := objCacic.getValueFromTags('te_help_etiqueta5', strConfigsPatrimonioInterface);
  544 + edTeInfoPatrimonio5.Text := strTeInfoPatrimonio6;
  545 + edTeInfoPatrimonio5.visible := True;
546 546 // end;
547 547  
548 548 // objCacic.writeDebugLog('MontaInterface: in_exibir_etiqueta6 -> "' +
... ... @@ -558,11 +558,10 @@ Begin
558 558 edTeInfoPatrimonio6.visible := True;
559 559 // end;
560 560  
  561 + btGravarInformacoes.Visible := true;
  562 + btCombosUpdate.Enabled := true;
561 563  
562   - btGravarInformacoes.Visible := true;
563   - btCombosUpdate.Enabled := true;
564   -
565   - Application.ProcessMessages;
  564 + Application.ProcessMessages;
566 565 end;
567 566  
568 567 procedure TfrmMapaCacic.FormClose(Sender: TObject; var Action: TCloseAction);
... ... @@ -586,7 +585,10 @@ begin
586 585 Except
587 586 on E:Exception do
588 587 Begin
  588 + MessageDlg(#13#13+'Problemas ao gerar formulário.',mtError, [mbOK], 0);
  589 + EstadoBarraTarefa(TRUE);
589 590 objCacic.writeExceptionLog(E.Message,e.ClassName);
  591 + Sair;
590 592 End;
591 593 End;
592 594 End;
... ... @@ -829,32 +831,40 @@ end;
829 831 function TfrmMapaCacic.LDAPName: string;
830 832 var
831 833 ldap: TLDAPsend;
832   - l: TStringList;
833   - host, username, psswd, base, strDadosLDAP, identificador : string;
  834 + identificador: TStringList;
  835 + i: integer;
  836 + host, username, psswd, base, strDadosLDAP, aux : string;
834 837 begin
835 838 result := '';
836 839 ldap := TLDAPsend.Create;
837   - l := TStringList.Create;
  840 + identificador:= TStringList.Create;
838 841 // PEGANDO OS DADOS DO POR MEIO DO GET/CONFIGS, ONDE SERÁ GRAVADO NO GERCOLS.INF
839 842 strDadosLDAP := objCacic.deCrypt(objCacic.getValueFromFile('Configs','Patrimonio_dados_ldap',strGerColsInfFileName));
840 843 host := objCacic.getValueFromTags('ip', strDadosLDAP);
841 844 username := objCacic.getValueFromTags('usuario', strDadosLDAP);
842 845 psswd := objCacic.getValueFromTags('senha', strDadosLDAP);
843 846 base := objCacic.getValueFromTags('base', strDadosLDAP);
844   - identificador:= objCacic.getValueFromTags('identificador', strDadosLDAP);
845   - try
846   - ldap.TargetHost := host;
847   - ldap.UserName := username;
848   - ldap.Password := psswd;
849   - ldap.Login; //Loga no LDAP.
850   - ldap.BindSasl; //Autentica no LDAP com Usuário e senha repassado. (BindSasl é mais seguro que Bind)
851   - l.Add(identificador); //Estamos pesquisando apenas o nome, então apenas 'cn' será enviado.
852   - ldap.Search(base, False, 'uid=' + getUserLogon, l); //Faz a pesquisa, com o CPF repassado.
853   - result := getLastValue(LDAPResultdump(ldap.SearchResult), #$D#$A);
854   - ldap.Logout;
855   - finally
856   - ldap.Free;
857   - l.Free;
  847 + for i := 0 to 2 do //Até 2 porque são no máxio 3 identificadores que serão passados.
  848 + begin
  849 + aux:=objCacic.getValueFromTags('identificador'+IntToStr(i+1), strDadosLDAP);
  850 + if aux<>'' then
  851 + identificador.Add(aux);
  852 + end;
  853 + if (host<>'') and (base<>'') then
  854 + begin
  855 + try
  856 + ldap.TargetHost := host;
  857 + ldap.UserName := username;
  858 + ldap.Password := psswd;
  859 + ldap.Login; //Loga no LDAP.
  860 + ldap.BindSasl; //Autentica no LDAP com Usuário e senha repassado. (BindSasl é mais seguro que Bind)
  861 + ldap.Search(base, False, 'uid=' + getUserLogon, identificador); //Faz a pesquisa, com o CPF repassado.
  862 + result := LDAPResultdump(ldap.SearchResult);
  863 + ldap.Logout;
  864 + finally
  865 + ldap.Free;
  866 + identificador.Free;
  867 + end;
858 868 end;
859 869 end;
860 870  
... ...