get current username from MWS

Hi Guys,

i have a problem to get the current username from an user wich is logged on, on the MWS and hope to find here an solution.

Issue/Description:
On MWS we used an LDAP Dircetory Service for authentification. If an User is logged on and use an application, I would like to get the current user name as an input for a service on IS for further work.

I try to use the “getUser” Service form PSUtilities, but even when a User is logged on I will get the username “Administrator”.

with kindly regards
Mario

I have a java service that returns a username may be you can try this way from Developer/Designer?

shared tab imports:
com.wm.app.b2b.server.ServerAPI
com.wm.app.b2b.server.Session
com.wm.app.b2b.server.InvokeState
com.wm.app.b2b.server.User
com.wm.app.b2b.server.Service

//Get the current session
Session currentSession = Service.getSession();

//Get current user
User user = currentSession.getUser();

//Assign the username value to strUsername
String strUsername = user.getName();

//insert the username into the pipeline
IDataCursor idcPipeline = pipeline.getCursor();
idcPipeline.insertAfter(“username”, strUsername);

HTH,
RMG

1 Like

Thanks for your fast reply,

I have implementet this Java service and he is returning the username form Administrator to.

Do you have any other ideas where the problem might be?

Thanks
Mario

This service returns the user name that logged in for that session…

Are you looking for only MWS specific logged in user for a session or all sessions?

HTH,
RMG

Hi RMG,

I would like to looking only for the specific logged in user for a session.

Cheers
Mario

I get that with the above mentioned code…who ever logged that session.

Crap, in this case there musst be a other problem, because I used your code an get just the name form administrator.

Do you have any other ideas ?

Nope…please check it again the service it shouldn’t give always as Administrator.

Hi Mario,
Try using below service.

wm.monitor.util:getCurrentUser

Yes this works as well the same as JS for MWS

Mario,Did the issue resolved yet?

Hi Guys,

yes, I solved this issue, but I used an other way.

At runtime off the portlet apllication I use a java principalmodel object to get the date from the current user and redirect this data with the initialize action to the input fields of an IS webservice for further work.

Thanks for your replys

Glad to hear about the resolution!

The reason you’re getting Administrator is because you’re calling the web service using simple authentication (type 1), with Administrator/password for the credentials.

To get the user’s credentials you need to be calling using hybrid authentication (type 3), which passes through the logged on MWS user’s credentials. Then just your web service permissions need to be set up to handle that, but at least you aren’t keeping your IS Administrator credentials in every portlet you deploy!

Thanks Rob for sharing the more information on this article: :smiley:

Hi Rob,

thanks too for this information, I will change the authentication method.

Regards Mario

After your change,please post your results back

Hi guys,

I’m having the same problem, i’ve changed authentication mode to hybrid(type 3) and using the java code to get user but it’s returning for me “Default”

//Get the current session
Session currentSession = Service.getSession();

//Get current user
User user = currentSession.getUser();

//Assign the username value to strUsername
String strUsername = user.getName();

//insert the username into the pipeline
IDataCursor idcPipeline = pipeline.getCursor();
idcPipeline.insertAfter("username", strUsername); 

Can anyone help me?
Thanks!