Skip to main content
1-Visitor
September 2, 2014
Solved

How to get user?

  • September 2, 2014
  • 5 replies
  • 4007 views

Hi.

How can i get current WTUser by java code?

I tried

WTPrincipal currentUser = SessionHelper.manager.getPrincipal();

and

MethodContext methodcontext = MethodContext.getContext();

methodcontext.mbean.getUserName();

Both of them don't work. They return "wcadmin" always.

Thanks.

Best answer by BjoernRueegg

When you launch a jsp page, you can use the following

<%

String username = wt.session.SessionHelper.getPrincipal().getName();

%>

Where is your code started from? Could it be that the code is running with administrator access?

5 replies

17-Peridot
September 2, 2014

When you launch a jsp page, you can use the following

<%

String username = wt.session.SessionHelper.getPrincipal().getName();

%>

Where is your code started from? Could it be that the code is running with administrator access?

1-Visitor
September 2, 2014

Hi, Björn.

I tried your code and it gave me correct result.

I'm loading applet from jsp.

Then i create wtpart from applet via wt.method.RemoteAccess.

The creator of my wtpart is defined as Administrator. How can i set the real creator?

Thanks.

17-Peridot
September 2, 2014

What shows the output if you call the method

RemoteMethodServer.getUserName()

and you aren't calling something like

SessionHelper.manager.setAdministrator();