on 10-30-2007 1:17 PM
Hi,
Can someone explain how to create a role dynamically for users on the portal? We have to create this dynamic portal role using a webdynpro application.
The scenario is like this: User logs into portal. Based on certain data available for this particular user I have to create a role dynamically. If data is not present for the user, we need not create the role.
Hope my query is clear. Please help resolve the problem. Thanks for the help.
Regards,
Chaitanya
Message was edited by:
chaitanya
Hi,
IUserFactory uFact = UMFactory.getUserFactory();
IRoleFactory rFact = UMFactory.getRoleFactory();
IRole test = rFact.getRoleByUniqueName(role1);
IUser me = request.getUser();
IUserMaint mutUser = uFact.getMutableUser(me.getUid());
mutUser.addToRole(test.getUniqueID());
mutUser.commit();
mutUser.save();
Warm Regards,
Murtuza
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Murtaza. According to the validation, the role is not created. I'm pasting my Java Webdynpro code below. Can you please have a look at it and tell me where i'm going wrong.
String role1 = "pcd:portal_content/THD/Test";
UserFactory userFact = UMFactory.getUserFactory();
IGroupFactory groupFact = UMFactory.getGroupFactory();
IRoleFactory roleFact = UMFactory.getRoleFactory();
IWDClientUser currentUser = WDClientUser.getCurrentUser();
IUser sapCurrentUser = currentUser.getSAPUser();
sapUser = sapCurrentUser;
String userId = currentUser.getClientUserID();
if (sapCurrentUser != null)
{
portalUserId = sapCurrentUser.getUniqueName();
wdComponentAPI.getMessageManager().reportSuccess("portal user id is"+ portalUserId);
testRole1 = roleFact.getRoleByUniqueName(role1);
IUserMaint modUser = userFact.getMutableUser(sapCurrentUser.getUid());
modUser.addToRole(testRole1.getUniqueID());
modUser.commit();
modUser.save();
if(sapCurrentUser.isMemberOfRole(testRole1.getUniqueID(),true))
{
wdComponentAPI.getMessageManager().reportSuccess("ROLE CREATED");
}
else
{
wdComponentAPI.getMessageManager().reportSuccess("ROLE NOT CREATED");
}
}
Regards,
Chaitanya
Hi
Try out by putting
modUser.save();
modUser.commit();
i.e save first and then commit
I was also facing the same problem.The role would have been assigned to the user at portal side but my checking condition is wrong.
Check out for the condition
modUser.isMemberOfRole(testRole1.getUniqueID(),true)
Regards
Akshaya
Hi chaitanya
Check this blog /people/michael.nicholls/blog/2006/08/09/dynamic-portal-role-assignment
Seems to be helpfull to you
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi! chaitanya,
Ues the UME API to create a role from webDynpro appl.link for UME API:--<a href="http://help.sap.com/javadocs/NW04/current/um/index.html">http://help.sap.com/javadocs/NW04/current/um/index.html</a>
use IRoleFactory to create a role or assign a role based on userInput.
Code for getting role will be like this..
IRoleFactory roleFact = UMFactory.getRoleFactory();
String[] str = roleFact.getRolesOfUser(UniqueIDOfUser,true);
let me know if you have any problem.
regards,
Mithileshwar
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.