Jump to content

Error login form


wandobh

Recommended Posts

Can you help me?
I have the following code in a login screen.
 
procedure TUniLoginForm2.UniButton1Click(Sender: TObject);
var
  adObject: IADs;
  Container : IADsContainer;
  User : IADsUser;
  hr : HREsult;
begin
  CoInitialize(Nil);
  try
    hr := ADsGetObject('LDAP://<Domain>',IADsContainer,Container);
 
    if Failed(hr) then exit;
 
    adObject :=  Container.Create(LowerCase(edtUsuario.Text),'ActiveDirectoryUser') as IADs;
 
    adObject.QueryInterface(IID_IADsUser, User);
 
    CoInitialize(Self);
    CoUninitialize;
 
    if Failed(ADsOpenObject('LDAP://<Domain>', LowerCase(edtUsuario.Text), edtSenha.Text, ADS_SECURITY_INFO_OWNER, IADs, adObject)) Then
       ShowMessage('Login inválido!')
    Else
       ModalResult := mrOk;
  except
    on e: EOleException do
    begin
      if Pos('Falha de logon', e.Message) > 0 then
        ShowMessage('Login inválido!')
      else
        ShowMessage(e.Message);
    end;
  end;
end;

 

 
But the CoInitialize error was not called

 

Link to comment
Share on other sites

  • 3 years later...
\FMSoft\Framework\uniGUI\Demos\Desktop\LoginForm

?

48 minutes ago, freedowsRoO said:

i have an ajax request and works perfectly passing 'mrOK' to ModalResult but the login form doesn't desappear.

Can you explain in more details?

  • Like 1
Link to comment
Share on other sites

On 1/30/2019 at 3:51 PM, Sherzod said:

\FMSoft\Framework\uniGUI\Demos\Desktop\LoginForm

?

Can you explain in more details?

 

Yes sure! I have a login form with a URLFrame and inside this URLFrame i have an ajaxRequest that works perfectly i can login normaly. When i put this same code on a HTMLFrame the ajaxRequest works but the login doesn't desapear.

Link to comment
Share on other sites

On 2/1/2019 at 1:33 PM, Sherzod said:

Hi,

Can you make a simple testcase for this?

 

Sorry, my application is to big to make a test case but i made a video with my problem. After i imput my login and password the login flashs before go to home page. This is a problema because for the client seems the login did not worked.

 

My login form just have one URLFRAME with this code:

 

<!DOCTYPE html>
<html lang="en">
<head>
	<title>UniSystemBI</title>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->	
	<link rel="icon" type="image/png" href="files/images/icons/favicon.ico"/>
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="files/vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="files/fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="files/fonts/iconic/css/material-design-iconic-font.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="files/vendor/animate/animate.css">
<!--===============================================================================================-->	
	<link rel="stylesheet" type="text/css" href="files/vendor/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="files/vendor/animsition/css/animsition.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="files/vendor/select2/select2.min.css">
<!--===============================================================================================-->	
	<link rel="stylesheet" type="text/css" href="files/vendor/daterangepicker/daterangepicker.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="files/css/util.css">
	<link rel="stylesheet" type="text/css" href="files/css/main.css">
<!--===============================================================================================-->
</head>
<body>
	
	<div class="limiter">
		<div class="container-login100" style="background-image: url('files/images/bg01.jpg');">
			<div class="wrap-login100">
				<form class="login100-form validate-form">
					

					<span class="login100-form-title p-b-34 p-t-27">
						Login
					</span>

					<div class="wrap-input100 validate-input" data-validate = "Enter username">
						<input class="input100" name="Username" type="text"  placeholder="Username" required="required">
						<span class="focus-input100" data-placeholder="&#xf207;"></span>
					</div>

					<div class="wrap-input100 validate-input" data-validate="Enter password">
						<input class="input100" name="Password" type="password"  placeholder="Password" required="required">
						<span class="focus-input100" data-placeholder="&#xf191;"></span>
					</div>

					
					<div class="container-login100-form-btn">
						<button class="login100-form-btn" type="submit" onclick="Login()" class="btn btn-primary btn-block btn-large" value="CONECTAR">
							Login
						</button>
					</div>

				</form>
			</div>
		</div>
	</div>

	 <script
  src="https://code.jquery.com/jquery-1.12.4.min.js"
  integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
  crossorigin="anonymous"></script>  
    <script src="files/js/index.js"></script>
    <script src="files/js/waitMe.min.js"></script>  

    <script language="JavaScript">
         function Login() {
         var LoginField = $("input[name=Username]");
         var SenhaField = $("input[name=Password]");		 
         top.ajaxRequest(top.UniLoginForm1.UniURLFrame1 , "Login",["usuario=" + LoginField.val(),"senha=" + SenhaField.val()]);         
      };
    </script>

</body>
</html>

 

My AJAX EVENT:

 

procedure TUniLoginForm1.UniURLFrame1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);

Var
bResult : boolean;
sValidaPassword : String;

begin
gsUsuario:=  Params.Values['usuario'];
gsSenha:=  Params.Values['senha'];
gsEvento:= EventName;

if gsEvento = 'Login' then
Begin
  try
    if (Trim(gsUsuario)<>'') and (Trim(gsSenha)<>'') then
    begin
      with UniServerModule.qrAuxiliar do
      begin
        Close;
        Sql.Clear;
        Sql.Add('SELECT US.NOME_USUARIO, US.SEQ_PLA_USUARIO, US.SENHA_USUARIO, US.APELIDO AS LOGIN_USUARIO');
        Sql.Add('  FROM USUARIOS US      ');
        Sql.Add(' WHERE US.NIVEL_ACESSO <> ''X'' ');
        Sql.Add('   AND US.APELIDO = :LOGIN');
        ParamByName('LOGIN').Value := StringReplace(Trim(gsUsuario),' ','',[rfReplaceAll]);
        try
          Open;
        except
        end;

        if (UniServerModule.qrAuxiliar.RecordCount = 1) then
        begin
          try
            //Valida se a senha é criptografada ou não por conta da diferença entre COMPASS e Mosaico
            if (UniServerModule.gsSenhaCriptografada = 'S') then
            begin
              sValidaPassword := UpperCase(UniServerModule.Cryptografia('D',UniServerModule.qrAuxiliar.FieldByName('SENHA_USUARIO').AsString));
            end else
            begin
              sValidaPassword:= StringReplace(Trim(gsSenha),' ','',[rfReplaceAll]);
            end;

            if (StringReplace(Trim(gsSenha),' ','',[rfReplaceAll]) = sValidaPassword) then
            begin
              UniMainModule.mAppSeqPlaUsuario := UniServerModule.qrAuxiliar.FieldByName('SEQ_PLA_USUARIO').AsString;
              UniMainModule.mAppLoginUsuario := UniServerModule.qrAuxiliar.FieldByName('LOGIN_USUARIO').AsString;
              UniMainModule.mAppIdDispositivo := UniApplication.Parameters.Values['id'];
              bResult:= true;
            end
            else
            begin
              showMessage('Usuário ou Senha Inválidos!');
              bResult := false;
              Inc(mTentativas);
            end;
          except
          end;
        end
        else
        begin
          showMessage('Usuário não encontrado ou inválido!');
          bResult := false;
          Inc(mTentativas);
        end;
      end;
    end;
  finally
    if (mTentativas > 3) then
    begin
      UniSession.Terminate('Aplicação Finalizada por Excesso de Tentativas de Login!');
    end;
  end;
End;
if (bResult = True) then ModalResult:= mrOk
Else ModalResult:= mrNone;
end;

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...