cancel
Showing results for 
Search instead for 
Did you mean: 

How can I fetch all the PCD roles from EP!

Former Member
0 Kudos
108

Hello,

I need to fetch all the available pcd roles in EP. Right now I am trying to fetch pcd roles under Portal Content directory. I need a clarification whether this is the only place the pcd roles are available or is there any other location where rest of the pcd roles are available?

Thanks in advance,

Prashanth V Swamy

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Prashanth,

We will get roles from two places. From PCD and another is LDAP. If you want to get PCD rooles search with RoleSearchFilters and Enumerate.

Just have a look this example

IRoleFactory iRoleF = UMFactory.getRoleFactory();

IRoleSearchFilter roleFlt = iRoleF.getRoleSearchFilter();

roleFlt.setUniqueName("*",ISearchAttribute.EQUALS_OPERATOR,false);

ISearchResult rslt1 = iRoleF.searchRoles(roleFlt);

if ( rslt1.getState() == ISearchResult.SEARCH_RESULT_OK ){

while (rslt1.hasNext()){

String roleUid = rslt1.next().toString();

...........

}

}

Best Regards,

Raja

Former Member
0 Kudos

Please refer the reply below.

Former Member
0 Kudos

Hi,

Just a small but useful addition in the code posted by Rahasekhar. In order to get the IRole object from the ISearchResult, you can use the following code:

ISearchResult rslt1 = iRoleF.searchRoles(roleFlt);

if ( rslt1.getState() == ISearchResult.SEARCH_RESULT_OK )

{

while (rslt1.hasNext())

{

<b>String roleUid = (String)rslt1.next();

IRole r = UMFactory.getRoleFactory().getRole(roleUid);</b>}

}

Now we can access all the usual methods available on the IRole object r.

Best Regards,

Vivek

Former Member
0 Kudos

Hi,

can anybody please attach a list of the used jar files?

I am not able to find Constants, PcdSearchControls,IPcdContext, etc.)

Thank you and kind regards, Patrick.

Former Member
0 Kudos

Hi ,

You need the following jars in order to get PCD contents.

1.com.sap.portal.pcd.glservice_api.jar

2.com.sap.portal.pcm.admin.apiservice_api.jar

3.com.sap.portal.ivs.api_portalpcm_api.jar

4.gl_api.jar

5.prtapi.jar

6.concurrency.jar

7.com.sap.portal.ivs.api_landscape_api.jar

Thanks and Regards

Radhika Kuthiala

Former Member
0 Kudos

Hi Prasanth,

See the code below to retrieve all the pcd roles.

public List getPCDContents(IPortalComponentRequest request) throws Exception{

try{

Hashtable env = new Hashtable();

env.put(IPcdContext.SECURITY_PRINCIPAL, request.getUser());

env.put(Context.INITIAL_CONTEXT_FACTORY,IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);

env.put(com.sap.portal.directory.Constants.REQUESTED_ASPECT, PcmConstants.ASPECT_SEMANTICS);

InitialContext ctx = null;

DirContext dirCtx;

List roleList = null;

ctx = new InitialContext(env);

dirCtx = (DirContext) ctx.lookup("pcd:portal_content/");

PcdSearchControls pcdSearchControls = new PcdSearchControls();

pcdSearchControls.setReturningObjFlag(false);

pcdSearchControls.setSearchScope(

PcdSearchControls.SUBTREE_WITH_UNIT_ROOTS_SCOPE);

dirCtx.addToEnvironment(

Constants.APPLY_ASPECT_TO_CONTEXTS,

Constants.APPLY_ASPECT_TO_CONTEXTS);

NamingEnumeration ne =

dirCtx.search("","(com.sap.portal.pcd.gl.ObjectClass=com.sapportals.portal.role)",

pcdSearchControls);

iViewList = new ArrayList();

while (ne.hasMoreElements()) {

IPcdSearchResult searchResult =

(IPcdSearchResult) ne.nextElement();

String location = "pcd:portal_content/" + searchResult.getName();

//Get the full pcd path of the iview.

roleList.add(location);

}

return iViewList;

}catch(Exception e ){

throw new Exception(e);

}

}

Hope it helps.

Regards,

Karthick

Former Member
0 Kudos

Hi,

Im not sure if i've got this right. But if you go to User Administration > Roles and then select 'roles' from the drop down list and click start, all the roles will be displayed.

Hope it helps

Former Member
0 Kudos

Hi Prashanth,

As of I know all the PCD Roles created in EP will be stored under PCD and not somewhere else.

As you are retrieving all the roles from PCD its enough and no need to get confused.

Regards,

Karthick Eswaran