Skip to Content
author's profile photo Former Member
Former Member

Adding users to role programmatically

Hi

I have a written a Portal Service which will accept the Portal user and Portal role. I am trying to adding Portal Role to the user programmatically using ume apis so that when the user logs in, he can see the Worksets related to this Portal Role.

I am passing the Portal user id and Portal role, But this is not working it is giving me an exception Portal Role is invalid, but I have this role in Portal.

What could be the problem?

Regards

Senthil

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 14, 2005 at 05:03 AM

    Hi Senthil,

    Try this code. It worked well for me.

    IUser iuser=UMFactory.getUserFactory().getUserByUniqueName("xxx");//give user id here
    IRole irole=UMFactory.getRoleFactory().getRoleByUniqueName("yyy");//give role name here
    
    String useruid=iuser.getUniqueID();
    String roleuid=irole.getUniqueID();
    
    UMFactory.getRoleFactory().addUserToRole(useruid,roleuid);

    Hope this solves your problem.

    Ranjith

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 14, 2005 at 04:27 PM

    Hi Ranjith

    Thanks for the code. It worked.

    This was the line which was missing in the code.

    IRole irole=UMFactory.getRoleFactory().getRoleByUniqueName

    Regards

    Senthil

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.