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>