Skip to Content
Former Member
Sep 20, 2006 at 11:49 AM

Getting the Subject (user principal) through JNDI


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!