Current Logged in User and Roles in ADF and Fusion Apps



A) Using the groovy Expression.

We can set default expression in view object attribute as below 
adf.context.securityContext.getUserPrincipal().getName() 
adf.context.securityContext.getUserName()  


For Roles use 

 
adf.context.securityContext.getUserRoles() 
   



B) Java Code
You can get User Name in Java code also using the following code.

     ADFContext adfCtx = ADFContext.getCurrent();  
     SecurityContext secCntx = adfCtx.getSecurityContext();  
     String user = secCntx.getUserPrincipal().getName();  
     String userName = secCntx.getUserName();
     String[]  Roles = secCntx.getUserRoles();

C) Expression Language
You can bind ADF Faces componenets with the following EL to get logged User Name.

 #{securityContext.userName}  
 #{securityContext.userRoles}  

D) In Fusion Applications (On Premise Implementation)

      ApplSession session = ApplSessionUtil.getSession();
      String guid1 = session.getUserGuid();

Comments

Popular posts from this blog

Executing a method bindings In Bean method.

Using Java Decompiler(JD) with Oracle Jdeveloper (Jdev)

Current Date in ADF.