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

User from portal

Hi,

I want to get the user ID details. I used this code and it provides me with the user id: name.surname

But from this I want to get the alias what shoud i add

try

{

IWDClientUser wdUser = WDClientUser.getCurrentUser();

IUser user = wdUser.getSAPUser();

if (user != null)

{

IUserAccount[] acct = user.getUserAccounts();

if(acct[0] != null)

{

String strUserid = acct[0].getLogonUid();

String strPasswd = acct[0].getHashedPassword();

IWDLabel myLabel = (IWDLabel)view.getElement("testLabel");

myLabel.setText(strUserid);

}

}

}

catch (Exception ex) {

ex.printStackTrace();

}

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 18, 2006 at 05:18 AM

    Hi,

    First you need to add the security.api.jar file.

    Procedure:

    1. Right click on project name >properties>java buildpath>Libraries>add variables>ECLIPS HOME>Extend> Plugins->com.sap.security>lib>com.sap.security.api.jar -->order and export.

    Write the below code in wddoinit()method for getting the portal logon user details .

    Create one or two context elements and bind it with UI elements.

    try {

    String firstName = WDClientUser.getCurrentUser().getFirstName();

    String lastName = WDClientUser.getCurrentUser().getLastName();

    String name = firstName + " " + lastName;

    wdContext.currentContextElement().setUserName(name);

    ISearchResult rst = UMFactory.getUserFactory().getUniqueIDs();

    IUser iuser = null;

    while (rst.hasNext()) {

    iuser = UMFactory.getUserFactory().getUser(rst.next().toString());

    if ((firstName.equalsIgnoreCase(iuser.getFirstName())) & (lastName.equalsIgnoreCase(iuser.getLastName()))) {

    String emailId = iuser.getEmail();

    wdContext.currentContextElement().setEmailid(emailId);

    }

    }

    } catch (WDUMException e) {

    e.printStackTrace();

    } catch (UMException ue) {

    ue.printStackTrace();

    }

    //@@end

    }

    Regards,

    Saraswathi.

    Pls reward points for useful information

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 17, 2006 at 02:49 PM

    Hi Eoin,

    Check

    https://media.sdn.sap.com/javadocs/NW04/SPS15/um/com/sap/security/api/IUser.html

    https://media.sdn.sap.com/javadocs/NW04/SPS15/um/com/sap/security/api/IPrincipal.html

    What is alias? I can only see IPrincipal.getDisplayName wich is <i>Gets the principal's display name. Depending on the implementation, this might be an alternative (<b>alias</b>) name</i>.

    Best regards, Maksim Rashchynski.

    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.