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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

How to get user?

VasiliyRepecki
12-Amethyst

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.

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());

Announcements


Top Tags