I'm trying to get windows username from liferay portlet in java code using javascript and active-x. When I run the code only with javascript and acitive-x on plain HTML it works. But when I put it in java, it doesn't work. Here is my code:
String script = "function getUser() {return ((new ActiveXObject('WScript.NetWork')).UserName); }";
try {
engine.eval(script);
} catch (ScriptException e) {
e.printStackTrace();
}
Invocable inv = (Invocable) engine;
try {
log.info("try invoke script");
String teste = (String) inv.invokeFunction("getUser");
log.info("meu teste " +teste);
} catch (ScriptException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
When I change the content on function for somthing else like returning string it prints the result.