How to get the logged in username using client context. I tried following code, but got admin as output, where as i want output as user logged in the geometrixx website.
Session session = resourceResolver.adaptTo(Session.class);
String userName=session.getUserID();
i guess this can be done using client context. Can anyone help me out getting username from client context.
Thanks in advance.
Solved! Go to Solution.
Views
Replies
Total Likes
In Javascript, you can do something like this to get the username:
CQ_Analytics.ClientContext.get("profile/authorizableId")
Regards,
Justin
Views
Replies
Total Likes
Views
Replies
Total Likes
A ClientContext represents a dynamically assembled collection of user data - not really the logged in user.
TO get user information/logged in users - you should be using Jackrabbit User Manager API.
Here is a community article that talks about how to use this API from within an OSGi:
Developing AEM OSGi bundles that use Jackrabbit UserManager APIs
Here is a StackOverflow thread with more info:
Views
Replies
Total Likes
Hi smacdonald2008,
Thanks for responding. my ultimate aim is to get logged in user name and i have used the above said API only.
i have 2 users one is logged in to CQ5 and another logged in to geometrixx site.
i want geometrixx site user.
can u share any code snippet by which i can get logged in username.?
Views
Replies
Total Likes
In Javascript, you can do something like this to get the username:
CQ_Analytics.ClientContext.get("profile/authorizableId")
Regards,
Justin
Views
Replies
Total Likes
Views
Like
Replies
Views
Likes
Replies
Views
Likes
Replies