JavaScript check if Windows user is enrolled in MS Access Bank

0

The need is to check if the Windows user is registered in the Ms Access Database, but it is not working as it should. I think the problem is in the variable strUserName inside the select.

I have tried in several ways but I still have not found the solution!

Does anyone know how to solve this?

< html > < body >


  <!-- PEGA USUARIO LOGADO NO WINDOWS -->

< script type = "text/javascript" >
var objNet = new ActiveXObject("WScript.NetWork");
var strUserName = objNet.UserName;
var strDomain = objNet.UserDomain;


document.write("Usuário: ", strUserName);



function abreRelJC() {

  var adoConn = new ActiveXObject("ADODB.Connection");
  var adoRS = new ActiveXObject("ADODB.Recordset");

  adoConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='P:\PCP\GERENCIAL\System\GERENCIAL_be.mdb'");
  adoRS.Open("Select * From CadastroUser WHERE UsuarioRelatorioGerencial = strUserName", adoConn, 1, 3);

  var Userbanco = adoRS.fields("UsuarioRelatorioGerencial").value;



  if (Userbanco == strUserName) {

    document.write("Ok! usuário cadastrado");

    adoRS.Close();
    adoConn.Close();
  } else {

    document.write("Usuário pendente de cadastro!");

    adoRS.Close();
    adoConn.Close();
  }

}


< /script>


<br / > < br / >


< input type = "button"
onclick = "abreRelJC()"
value = "Testa usuáro"
style = "font-size:20px; color:SlateGray" / >


  < /body>< /html>
    
asked by anonymous 14.07.2015 / 14:50

1 answer

1

You've tried:

adoRS.Open("Select * From CadastroUser WHERE UsuarioRelatorioGerencial = " + strUserName, adoConn, 1, 3, 1);

?

In the same way in document.write:

document.write("Usuário: " +  strUserName);

If the network console or javascript returns an error, please post it

Correction: Try      adoRS.Open ("Select * From CadastroUser WHEREUserGrabicReport=" + strUserName, adoConn, 1, 3, 1);

    
14.07.2015 / 15:01