cancel
Showing results for 
Search instead for 
Did you mean: 

How to get ECC Mapped UserID

ashwani_tomar
Participant
0 Kudos

Hi ,

I need to get the ECC Mapped USerID (mapped in portal) and pass it to a BAPI. ANy Idea how do I get it from UME once it is mapped in Portal.

Thanks,

-Ashwani

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Aswani,

Use the following Code:

try {

			IWDClientUser user = WDClientUser.getCurrentUser();
			String userid = user.getSAPUser().getDisplayName();
					} catch (WDUMException ex) {
			wdComponentAPI.getMessageManager().reportException(
				ex.getMessage(),
				false);
		}

With this code, you can get the USERID, DISPLAY NAME, or whatever you want.

/Raj Peddisetty.

ashwani_tomar
Participant
0 Kudos

Raj,

I want for Mapped User API's . I need the backend UserID which is mapped into the portal. I ahve been using this code but getting error. I have already added the required .jar file(com.sap.portal.usermanagementapi.jar) but still it says "IPortalComponentRequest" unresolved. Let me know if you have any clue

IPortalComponentRequest req = (IPortalComponentRequest) this.getRequest();

IUserMappingService iumser = (IUserMappingService) PortalRuntime.getRuntimeResources().getService

(IUserMappingService.KEY);

IUserMappingData iumdata = iumser.getMappingData("System Alias", req.getUser());

Map map = new HashMap();

try {

iumdata.enrich(map);

} catch (Exception e) {}

String userid = (String)map.get ("user");

Former Member
0 Kudos

Hi,

Have you added sharing references to the said portal service in your web dynpro project? But do you really need to use IPortalComponentRequest? An easier way would be:


IWDClientUser loggedInUser  = WDClientUser.getLoggedInClientUser();
IUser sapUser               = loggedInUser.getSAPUser();
IUserMapping allUserMapping = UMFactory.getUserMapping();
 
try {
String backEndUserName = allUserMapping.getR3UserName (sapUser, &quot;<system ID>&quot;, null, true);
}
catch (UMException e) {
  //log
}

Regards,

Satyajit.

Former Member
0 Kudos

Aswani,

You cant use IPortalComponentRequest in Web Dynpro. Use my code or satyajit's in Web Dynpro. Either one works fine. But you cant use IPortalComponentRequest at all in Web Dynpro. Otherwise if you want to use that, go for JSP DynPage.

/Raj Peddisetty.

ashwani_tomar
Participant
0 Kudos

Guys,

Your ssuggestions solved my problem. Thanks alot. I have awarded points to both of you

Answers (1)

Answers (1)

siddharth_jain
Active Contributor
0 Kudos

Hi,

if you are using WD then your code will work will little modifications:

IWDClientUser user = WDClientUser.getLoggedInClientUser();

Iuser puser = user.getSAPUser();

IUserMappingService iumser = (IUserMappingService) WDPortalUtils.getServiceReferences.(IUserMappingService.KEY);

IUserMappingData iumdata = iumser.getMappingData("System Alias",puser);

Map map = new HashMap();

try {

iumdata.enrich(map);

} catch (Exception e) {}

String userid = (String)map.get ("user");

IWDClientUser and WDPortalUtils Api is already provided by webdynpro runtime,

apart from this you have to add saaj-api.jar ,usermapping_api.jar which you have already included,

and com.sap.security.api.jar for iuser.

if you are using NWDI then these jars excluding usermapping api jars are available in webservice and com.sap.security.api.sda lib dcs.

finally in webdynpro shared references you have to give the references like this:-

PORTAL:sap.com/com.sap.portal.usermapping

Regards,

Siddharth

ashwani_tomar
Participant
0 Kudos

Thanks Siddharth