Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Searching and displaying Roles for a user


I want to access roles, worksets, iviews for logged on user.

I am using following piece of code which gives me ALL roles and other PCD contents in portal.

IUser iUser = WDClientUser.getCurrentUser().getSAPUser();
Hashtable env = new Hashtable();
env.put(IPcdContext.SECURITY_PRINCIPAL, iUser);
env.put(, PcmConstants.ASPECT_SEMANTICS);
InitialContext ctx = null;
DirContext dirCtx;
ctx = new InitialContext(env);
dirCtx = (DirContext) ctx.lookup("pcd:portal_content/");
PcdSearchControls pcdSearchControls = new PcdSearchControls();

NamingEnumeration ne ="","(",pcdSearchControls);

Any idea how can I get details of the roles for specific user (in this case, logged on user)?

Thanks and regards,


Former Member replied

Hi Arney,

I am not sure whether I completely understand your issue... but anyway, maybe you can solve your issue in a different way. Take a look at [|], especially at the method getNavNodes(...).

All reachable navigation entries for the current user are fetched in here. This is much more easier, faster and cleaner than traversing the PCD...

If this doesn't fit your needs, then you can e.g. traverse the PCD and test for every found role whether the current user is assigned to it or not (this is however of course not very efficient... maybe there exist more efficient ways...). But you have also to take care of the "entry point" property. Only if this is set to true a role will appear in the top level navigation (furthermore if a role has not set this attribute, but e.g. a subfolder of a role has this property set, then this subfolder will appear in the top level navigation).

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question