cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

How to get user?

VasiliyRepecki
1-Newbie

How to get user?

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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?

View solution in original post

5 REPLIES 5

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?

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.

What shows the output if you call the method

RemoteMethodServer.getUserName()

and you aren't calling something like

SessionHelper.manager.setAdministrator();

RemoteMethodServer.getDefault().getUserName(); returns null

otherwise you have to try somehting like

WTPrincipal localPrincipal = SessionHelper.manager.getPrincipal();

SessionHelper.manager.setPrincipal(localPrincipal.getName());

Top Tags