Show TOC

Background documentationAccessing the PCD from a J2EE Application Locate this document in the navigation structure

 

J2EE applications can access content stored in the Portal Content Directory (PCD) using JNDI.

In the following example, a Web Dynpro application accesses an object in the PCD. The content of the PCD is protected against impermissible access. Therefore, the SAP UME user must be put in the JNDI environment to identify the current user. In the example below this user is obtained from the Web Dynpro specific user.

The example shows the lookup of the data only. The IntialContext is a javax.naming class.

Syntax Syntax

  1. import com.sap.tc.webdynpro.services.sal.um.api.WDClientUser;
  2. import com.sap.security.api.IUser;
  3.  
  4. // class implementation
  5.  
  6.    // method implementation
  7.  
  8.       // getting the SAP user.
  9.       IUser currentUser = WDClientUser.getCurrentUser().getSAPUser();
  10.  
  11.       Hashtable env = new Hashtable();
  12.       env.put(Context.SECURITY_PRINCIPAL, currentUser);
  13.  
  14.       try {
  15.          InitialContext context = new InitialContext(env);
  16.  
  17.          Object obj = context.lookup(
  18.          "pcd:/com.sap.portal.system/applications/
  19.           com.sap.portal.ivs.global/services/producer");
  20.  
  21.       } catch (NamingException e) {
  22.          // handle the exception
  23.       }
End of the code.