I am trying to get user name for logged in user in alfresco using
String name = serviceRegistry.getAuthenticationService().getCurrentUser();
But it always return admin regardless of which user is logged in.
Then i tried
String name = AuthenticationUtil.getFullyAuthenticatedUser();
It also returns admin for all users.
I googled it without any success. Is it a bug in alfresco or do i need to take care of something else also to get appropriate user name?
Or is there any other way to get currently logged user name?
String name = AuthenticationUtil.getFullyAuthenticatedUser();
is the correct way to get the userName of your current user.
Every webscript has an descriptor where you can configure the authentication that is required to execute the webscript: http://docs.alfresco.com/4.2/references/api-wsdl-authentication.html
Typically, you will use <authentication>user</authentication>
There are two different 'runtimes' in the alfresco repo that can be used to execute a webscript: