Page 1 of 1

loginUserFromVault with JavaScript

Posted: Wed Nov 29, 2017 9:28 pm
by dan7777777
Has anybody been able to achieve this?
I would like to use this for a doAsUser method, but I'm not able to get the subject object. Whenever I try to use the method, I get this error on my browser console:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)

This is my code:

Code: Select all

var subject = securityService.loginUserFromVault("vaultKey", "test");
var JavaPackage = new JavaImporter(;
with(JavaPackage){securityService.doAsUser(subject , new PrivilegedAction(){
            run: function() {
                    securityService.addContextRoleToUser(userId, role, contextId);

Any information would be amazing!

Re: loginUserFromVault with JavaScript

Posted: Thu Nov 30, 2017 2:17 pm
by dan7777777
After adding try-catch blocks I get a more specific error:

Why would this be occurring?