cancel
Showing results for 
Search instead for 
Did you mean: 

Pass UserId from portal to application

Former Member
0 Kudos

Hi,

I am trying to create one Web dynopro java application which should be able to display the User Id and password which is entered in the portal. This application i want to lonch in SAP EP.

Can Any one help me.

I checked in Sdn i got information like we need two jar file called

com.sap.security.api.jar. and com.sap.security.api.perm.jar and Where do i get these jar file.

i have writen code like this.

try
	           {
		IWDClientUser wdUser = WDClientUser.getCurrentUser();
                                 IUser user = wdUser.getSAPUser();
		wdComponentAPI.getMessageManager().reportSuccess(""+user);
	            }
	        catch(UnknownError e)
		{
		   wdComponentAPI.getMessageManager().reportSuccess("hello");
		}

But i am getting Error like this.

This compilation unit indirectly references the missing type com.sap.security.api.IUser (typically some required class file is referencing a type outside the classpath)

I want the solution for this.

Regards,

H.V.Swathi

Edited by: H.V Swathi on Jan 3, 2009 11:30 AM

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

This code should be placed with the jar file in application

try {

IWDClientUser wdUser = WDClientUser.getCurrentUser();

user = wdUser.getSAPUser();

String str1 = user.toString();

if (user != null) {

// access logon ID by iterating through the IUserAccount array

IUserAccount[] acct = user.getUserAccounts();

if (acct[0] != null) {

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

// pass the value obtained from the portal to value attribute

wdContext.currentContextElement().setTest(strUserid);

wdComponentAPI.getMessageManager().reportSuccess("" + strUserid);

}

}

} catch (Exception e) {

wdComponentAPI.getMessageManager().reportSuccess("hello");

}

Former Member
0 Kudos

Hi

Right click on the Project ,

Click - properties

Java Build Path - Libraries tab - external Jars - select the jar file from eclipse plugins com.sap.security_2.0.0- lib - com.sap.security.api.jar file- and click on open button

This will add the required jar file to the project.

Similarly add other jarfiles which u want.

If you feel problem in browsing plugin folder , you can find in Program Files \SAP\ IDE \IDE70 \eclipse\ plugins

Thanks,

Srini

Edited by: srinivasa rao on Jan 3, 2009 2:55 PM

Former Member
0 Kudos

Hi,

If you are developing without use NWDI, you will need of com.sap.security.api.jar, it is under:

<NWDS_DIR>eclipsepluginscom.sap.security_2.0.0lib, so you can add it to you classpath, like show on this document: https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0bd5112-4456-2b10-c28b-9654d5ae...

The com.sap.security.api.perm.jar file can be found on

<NWDS_DIR>eclipsepluginscom.sap.tc.ap_2.0.0compSAP-JEEDCssap.comcom.sap.security.api.sda\_compgendefaultpublicdefaultlibjava

If you are using DC, you don't need to add this file to you classpath directly, you must to add a DC as used.

In the Web Dynpro Explorer, select your DC and navigate to DC MetaData > DC Definition > Used DC. Right click Used DC and choose Add Used DC. Select SAP-JEE > com.sap.security.api and click Finish. Possibly you can/should right click on your DC and choose Development Component > Sync Used DCs. Your project should build/deploy/run fine now.

Best regards

Former Member
0 Kudos

Hi,

Thanks for your Reply. Your answer was really helpful but after putting that application in the portal i am getting this result can u help me to solve the issue . I want that user name and pass word to be printed on the web dynpro page

this is the result i got

Welcome

Transient data: *************************************************************************** * com.sap.security.core.persistence.imp.PrincipalDatabag Mon Jan 05 11:26:15 IST 2009 * UniqueID: USER.R3_DATASOURCE.JKTUSER * Type: USER * Home data source: R3_DATASOURCE * Private id part: JKTUSER * * Existence not checked. * * "com.sap.security.core.usermanagement"|->"j_authscheme" (no time limit)="basicauthentication" * "com.sap.security.core.usermanagement"|->"MYSAPSSO2_STRING" (no time limit)="AjExMDAgAA5wb3J0YWw6SktUVVNFUogAE2Jhc2ljYXV0aGVudG... (total length: 484 characters)" *************************************************************************** Persistent data: *************************************************************************** * com.sap.security.core.persistence.imp.PrincipalDatabag Mon Jan 05 11:26:15 IST 2009 * UniqueID: USER.R3_DATASOURCE.JKTUSER * Type: USER * Home data source: R3_DATASOURCE * Private id part: JKTUSER * * Principal exists. * * Direct parents: * GRUP: GRUP.PRIVATE_DATASOURCE.un:ROOM_5052a7be-7fb0-2b10-c28f-9ab7a9b07344_MAIN * GRUP.R3_ROLE_DS.SAP_J2EE_ADMIN * GRUP.SUPER_GROUPS_DATASOURCE.EVERYONE * GRUP.PRIVATE_DATASOURCE.un:ROOM_7017c585-47b5-2b10-43a4-adb4a4f1f30f_MAIN * GRUP.PRIVATE_DATASOURCE.un:ROOM_809cc720-596c-2b10-38a7-ca6de0c60359_MAIN * GRUP.PRIVATE_DATASOURCE.un:ROOM_70bcf62e-81b0-2b10-ee99-ed37a6bbbc1e_MAIN * GRUP.PRIVATE_DATASOURCE.un:Administrators * GRUP.SUPER_GROUPS_DATASOURCE.AUTHENTICATED_USERS * "com.sap.security.core.usermanagement"|->"accessibilitylevel" (no time limit)="1" * "com.sap.security.core.usermanagement"|->"mobile" (no time limit)= * "com.sap.security.core.usermanagement"|->"title" (no time limit)= * "com.sap.security.core.usermanagement"|->"uniquename" (no time limit)="JKTUSER" * "com.sap.security.core.usermanagement"|->"telephone" (no time limit)= * "com.sap.security.core.usermanagement"|->"salutation" (no time limit)="Mr." * "com.sap.security.core.usermanagement"|->"jobtitle" (no time limit)= * "com.sap.security.core.usermanagement"|->"displayname" (no time limit)= * "com.sap.security.core.usermanagement"|->"fax" (no time limit)= * "com.sap.security.core.usermanagement"|->"department" (no time limit)= * "com.sap.security.core.usermanagement"|->"APPROVAL_REQUEST_COMPANYID" (no time limit)= * "com.sap.security.core.usermanagement"|->"company" (no time limit)= * "com.sap.security.core.usermanagement"|->"lastname" (no time limit)="EPuser" * "com.sap.security.core.usermanagement"|->"locale" (no time limit)="en" * "com.sap.security.core.usermanagement"|->"timezone" (no time limit)="IST" * "com.sap.security.core.usermanagement"|->"firstname" (no time limit)= * "com.sap.security.core.usermanagement"|->"email" (no time limit)="" * "com.sap.security.core.usermanagement"|->"referenceuser" (no time limit)= * "com.sapportals.portal.navigation"|->"uipmode" (no time limit)="2" * "$serviceUser$"|->"SERVICEUSER_ATTRIBUTE" (no time limit)= ***************************************************************************

Regards,

H.V.Swathi

Edited by: H.V Swathi on Jan 5, 2009 7:03 AM

Former Member
0 Kudos

Hi Swathi,

Dont print user object directly.

get the reltaed information that you want from user object.

wdComponentAPI.getMessageManager().reportSuccess("user name "+user.getUniqueName);

wdComponentAPI.getMessageManager().reportSuccess("UserId "+ user.getUid);

Regards,

Sandeep.

srinivas_sistu
Active Contributor
0 Kudos

Hi,

In your success messgae, you are printing user , instead of this print

user.getuniquename().... this will give you the user's login Id.

sample:

IWDClientUser user=WDClientUser.getCurrentUser();

IUser myuser=null;

myuser=user.getSAPUser();

wdContext.currentContextElement().setVa_EmpId(myuser.getUniqueName());

Regards,

Srinivas