cancel
Showing results for 
Search instead for 
Did you mean: 

User from portal

Former Member
0 Kudos

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();

}

Accepted Solutions (1)

Accepted Solutions (1)

saraswathi_d
Participant
0 Kudos

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

Former Member
0 Kudos

I want to get the usermapping ID from the portal, now i get the userID from the JCO connection

Former Member
0 Kudos

Your Modeldata JCO connection should be created via SAP logon ticket, instead of userid and password

Former Member
0 Kudos

this solved my problem

Answers (1)

Answers (1)

former_member182372
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

the alias is the inlognam for the back-end this one is different from the portal

former_member182372
Active Contributor
0 Kudos

Hi Eoin,

Sorry, still not clear. What is inlognam? Do you need information about user mapping? Check

Best regards, Maksim Rashchynski.