wandobh Posted July 28, 2015 Share Posted July 28, 2015 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 Quote Link to comment Share on other sites More sharing options...
DoiSuthep Posted July 28, 2015 Share Posted July 28, 2015 Hi, You just need to initialize COM library by: Coinitialize(nil) Google "coinitialize(nil) delphi" for more info. Quote Link to comment Share on other sites More sharing options...
wandobh Posted July 28, 2015 Author Share Posted July 28, 2015 I've done it and yet still the same error I started CoInitialize both servermodule as the mainmodule and does not work Quote Link to comment Share on other sites More sharing options...
DoiSuthep Posted July 28, 2015 Share Posted July 28, 2015 Maybe UniServerModule->AutoCoInitialize->True helps. Check also: http://forums.unigui.com/index.php?/topic/2804-ldap/?hl=coinitialize&do=findComment&comment=12937 Quote Link to comment Share on other sites More sharing options...
freedowsRoO Posted January 30, 2019 Share Posted January 30, 2019 Reviving the topic. I have an issue with the login form, i have an ajax request and works perfectly passing 'mrOK' to ModalResult but the login form doesn't desappear. What can it be? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 30, 2019 Share Posted January 30, 2019 \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? 1 Quote Link to comment Share on other sites More sharing options...
freedowsRoO Posted February 1, 2019 Share Posted February 1, 2019 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. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 1, 2019 Share Posted February 1, 2019 Hi, Can you make a simple testcase for this? Quote Link to comment Share on other sites More sharing options...
freedowsRoO Posted February 5, 2019 Share Posted February 5, 2019 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=""></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=""></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; Video_1549360852.wmv Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 5, 2019 Share Posted February 5, 2019 54 minutes ago, freedowsRoO said: the login did not worked Ie, login form does not close for some time? Quote Link to comment Share on other sites More sharing options...
freedowsRoO Posted February 5, 2019 Share Posted February 5, 2019 No, the login form does not close. I made a simple test and just put the code: "ModalResult:= mrOk" in Ajax event and it work! For some reason the problem only occurs when i type the user and password in the fields. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 5, 2019 Share Posted February 5, 2019 1 hour ago, freedowsRoO said: No, the login form does not close. Sorry, I did not fully delve into your code, but you can try without <form> tag 1 Quote Link to comment Share on other sites More sharing options...
freedowsRoO Posted February 6, 2019 Share Posted February 6, 2019 Thank you @Sherzod i remove the tag 'FORM' and it worked! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.