Showing results for 
Search instead for 
Did you mean: 

Getting the Subject (user principal) through JNDI

Former Member
0 Kudos

Hi, I'm currently migrating a JBoss AS application to SP NetWeaver (NetWeaver 2004 sp15). At some point in the application, audit trails are created to track user changes on certain data. The audit trail class uses a JNDI lookup to get the Subject (user principal) which is performing the changes. This is done by a JNDI lookup:

InitialContext ctx = new InitialContext();

Subject subject =

(Subject) ctx.lookup("java:comp/env/security/subject");

Object[] principals = subject.getPrincipals().toArray();

Principal principal = (Principal)principals[0];

String username = principal.getName();

However, this does not work in SAP NetWeaver. The JNDI path to the Subject is not found. Can anybody tell me which JNDI path I must use to get the Subject? Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Well, the JNDI-Name is somewhat JBoss specific I think:

As to be read <a href="">here</a>

>Subject-based authorization

>If you use the standard JBoss JaasSecurityManager to handle

>your security, then you can obtain the currently active

>JAAS Subject as an alternative to calling EJBContext

>methods. The subject is an instance of

> that is set for the invocation.

>You can use JNDI (Java Naming and Directory Interface) to

>obtain a reference to it, as follows:


Now two ways to continue:

a)look at any dokumentation concerning JAASContext in SAPWebAS and try to find anything usefull...

b)deploy a web.xml with your project, defining the security manager to use...

Look at your JBoss where this JNDI-Name comes from (it has to be deplyed somewhere, look at the jmx-console for instance) and find anything similar in SAPWebAS!

Good Luck!

Answers (1)

Answers (1)

Former Member
0 Kudos

Reposting....any ideas?? Thanks.