cancel
Showing results for 
Search instead for 
Did you mean: 

Obtaining SAP User information from J2EE Application

Former Member
0 Kudos

Hi All,

I am using SAP NetWeaver Developer Studio to create a J2EE Application, which requires accessing user information from SAP coming from Windows Active Directory.

My question is as follows;

Is there a possibility in a J2EE application to use an API to obtain user information (ie. from com.sap.security.api.jar) just like in a regular WebDyn Pro Application?

For Archive Build Info (compile time), do I need to import specific JARs? For runtime, do I need to load any project reference?

Thanks in advance,

Michael

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Michael

It sounds like you're using a local project (i.e. not using NWDI). The recommended approach is to create a local DC containing your Java project.

Once this has been done, you can reference the tc/bl/security/lib DC in the ENGFACADE SC. This should give you access to the SAP security api. No need to add any jar references if you're using a DC project, as everything is done through SC references.

Your question sounds a little ambiguous to me, so I'm assuming you just want to access user data in the UME, rather than directly querying Active Directory using LDAP?

You can then add a reference to this library in your application-j2ee-engine.xml file (in the associated EAR project).

Just use the UMFactory class to get access to all the security info you need. Documentation can be found here: [http://help.sap.com/javadocs/nwce/current/se/SP5/index.html]

Let me know if you need further help.

Former Member
0 Kudos

Stuart,

Thanks a lot for your elaborate solution, it is working fine now.

Now I am trying to connect from my J2EE application to a MS SQL Server Database via JDBC.

I am not able to successfully connect, and am getting the following error:

"Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial"

The following code is used to get the connection:

InitialContext ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("jdbc/" + dataSourceName);

conn = ds.getConnection();

The exact same code is working fine within a Web DynPro project, so I don't think there is an issue with JDBC setup on the J2EE Web Server. Do you have any idea as to why I am unable to connect when using a J2EE Application instead?Am I missing something critical?

Thanks in advance,

Michael

Former Member
0 Kudos

Hi Michael

Unfortunately I haven't done any development connecting to databases directly - only using JPA within the SAP database.

Hopefully someone else can provide some assistance here.

Former Member
0 Kudos

Hi Stuart, no proplem, thanks.

When you said :

>>you can reference the tc/bl/security/lib DC in the ENGFACADE SC. This should give you access to the >>SAP security api.

I am unable to find ENGFACADE SC. Where should this be located?

Former Member
0 Kudos

Should be in your local development configuration.

If you're using NWDI, you'll need to import the relevant SCA file and set build-time dependencies within your SLD.

Former Member
0 Kudos

Hi

I have the same working from a Java project in my ear (JEE). Or instead of lookup you shall use annotation as well if u r in a managed class e.g



@Resource
(name = "jdbc/efsDataSourceu201D, type = javax.sql.DataSource.class)
 private DataSource dataSource;   

HTH

Regards

LNV

Answers (0)