cancel
Showing results for 
Search instead for 
Did you mean: 

getUserAccounts() of com.sap.security.api IUser

Former Member
0 Kudos

Hello All,

Referring to UME Javadocs : https://media.sdn.sap.com/javadocs/NW04/SP9/ume/index.html

Method of : com.sap.security.api Interface IUser

getUserAccounts() 
Returns an array of useraccounts objects which are assigned to the user.

Now what is the meaning of <b>array of useraccounts</b>, b'coz IUser corresponds to single unique user.

Now how a user having a unique id can have multiple user accounts.

Please explain in details.

regards

Santosh

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Santosh,

queted from:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/91f0cd90-0201-0010-a190-c4d...

In EP5 you could simply call getUid() to obtain the logon ID. However, you will notice that this method is deprecated in EP6. This is primarily due to the fact that a user can be associated with multiple logon accounts. The Javadocs say to use getUniqueId() as a replacement for getUid(), but this returns a value that must be parsed to get the logon ID. You can access the actual logon ID by iterating through the IUserAccounts array obtained by calling getUserAccounts(). The logon ID is retrieved using the new call getLogonUid(). Often times you can simply pick the first element in the array:

String logonID = user.getUid();
IUserAccount accounts[] = null;
try {
    accounts = user.getUserAccounts();
} catch (UMException e) {
    response.write(("<br>Error getting accounts: " + e.getLocalizedMessage());
}
if (accounts != null) {
    response.write("<br>Number of Login Accounts: " + accounts.length);    

    for (int i = 0; i < accounts.length; i++) {
        response.write(
            "<br>** Login ID #"    + i
                + ": LogonUID="    + accounts[ i ].getLogonUid()
                + ", AssignedUID=" + accounts[ i ].getAssignedUserID());
        response.write(
            "<br>Last Login: "
                + accounts[ i ].getLastSuccessfulLogonDate().toString());
        response.write(
            "<br># Logins: " + accounts[ i ].getSuccessfulLogonCounts());
    }
}

Hope That helps,

Yoav.

Former Member
0 Kudos

Hi Yoav,

I believe that in EP userID = LoginID.

So in your above give code, stmt as:

String logonID = user.getUid()/UniqueID();

would definitely return uniqueID of only one user.

So if this is true, how can I retrieve multiple user accounts of a particular EP user?

<u>In other words</u>,

When I create EP user from User Administration in EP, the first field I need to put in is the UserID which is taken to be the LoginID.

When I retrieve the Unique ID of this newly created EP user, the returned loginid string is concatinated with the userid (<i>which is loginid</i>) of the user.

If true, then we need to think of someother key by which we can differenciate an EP user.

Please guide.

Awaiting Reply.

Thanks and Warm Regards,

Ritu R Hunjan

former_member183890
Participant
0 Kudos

Hi,

This method return you an array of the IUser object. We can use the enumeration techniques to get the IUser data for every user.

Thanks.

Regards,

Peter

Former Member
0 Kudos

Hi Peter,

Sorry i didn't understood ur reply.

Referring to the code below:

IUserFactory userfactory = UMFactory.getUserFactory();

IUser user = userfactory.getUserByLogonID("AAA");

// Now this method....

IUserAccount accounts[] = user.getUserAccounts();

Returns all accounts of user AAA.

Since user AAA (LoginID of user AAA) is unique and will have only one account, right then ,what is the purpose of this method.

regards

Santosh

Former Member
0 Kudos

Hi Yoav,

Thanks for ur good explanation.

What i understood from ur reply is,

A portal user can have multiple login ids. ie a unique user id can corresponds to multiple login ids.

Now next question which comes to my mind is when a user is created he is assigned a unique login id, Now how to assign him multiple login ids.

regards

Santosh

Former Member
0 Kudos

<u>Santosh:</u>

I dunno.

Anyone else?

<u>Ritu:</u>

I'm not sure I understand.

Can you please try to clarify your question?

Message was edited by: Yoav Gur