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

Retrieve all user accounts for a particular EP user.....:|

Hello All,

I want to how can I retrieve all the user accounts of a particular EP user?

Example:

Suppose EP user named Ritu, has 3 user accounts in EP like

ritu1, ritu2 and ritu3.

Now I need to write a code using which I can count all the useraccounts(ritu1, ritu2 and ritu3) that Ritu has along with login-id for each of them.

-


Ive referred to IUserAccount API but am not able to get the desired output.

Am getting confused actually.

Had written this code but its not giving me what I want ==>

import com.sap.security.api.*;

import com.sap.security.api.IUser;

import com.sap.security.api.IUserAccount;

import com.sap.security.api.IUserFactory;

import com.sap.security.api.UMFactory;

import com.sapportals.portal.prt.component.AbstractPortalComponent;

import com.sapportals.portal.prt.component.IPortalComponentRequest;

import com.sapportals.portal.prt.component.IPortalComponentResponse;

public class userAccounts extends AbstractPortalComponent

{ public void doContent( IPortalComponentRequest request, IPortalComponentResponse response)

{ try

{ IUserFactory userfact = UMFactory.getUserFactory();

IUser iuser = userfact.getUserByLogonID("rituh");

IUserAccountFactory useraccountfact = UMFactory.getUserAccountFactory();

IUserAccount userac= useraccountfact.getUserAccountByLogonId("rituh");

IUserAccount useraccount[]=useraccountfact.getUserAccounts(iuser.getDisplayName());

for(int i=0; i<useraccount.length;i++)

response.write("<br>User Accounts = " + useraccount<i>.getLogonUid());

}

catch(Exception e)

{ response.write("<br> Error => " + e.getMessage());

}

}

}

Please help me.

Awaiting Reply.

Warm Regards,

Ritu R Hunjan

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Oct 20, 2005 at 09:09 AM

    Hi Ritu,

    Try the following code:

    IUserAccount iuacc[]=iuser.getUserAccounts();
    for(int j=0; j<iuacc.length;j++)
    {
    response.write("<br>User Accounts = " + iuacc[j].getLogonUid());
    }

    instead of:

     IUserAccountFactory useraccountfact = UMFactory.getUserAccountFactory();
    IUserAccount userac= useraccountfact.getUserAccountByLogonId("rituh");
    
    IUserAccount useraccount[]=useraccountfact.getUserAccounts(iuser.getDisplayName());
    for(int i=0; i<useraccount.length;i++)
    response.write("<br>User Accounts = " + useraccount.getLogonUid());

    This might solve your problem.

    Ranjith

    Message was edited by: Ranjith Vijayan

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Ranjith,

      Please tell me how am I gonna get the instance "iuser".

      Is it:

      IUser user = userFactory.getUserByUniqueName("santosh") OR

      IUser user = userFactory.getUserByLogonID("santosh")

      Am aksing you this 'coz in EP UserID = LogonID.

      So when I retrieve the Unique ID of an user, the returned uniqueID is concatinated with the userid (i.e. logonid) of the user).

      So if this is rite, then this above code would only return 1 as the useraccount.

      Please guide.

      Awaiting Reply.

      Thanks and Warm Regards,

      Ritu R Hunjan

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.