Friday, June 21, 2013

How to get current logged In User information in ADF ?

How to obtain Logged In User information in ADF ?

Below are multiple ways how we can obtain the logged in User specific information in ADF
UI Layer
--------------------------
 #{securityContext.userName}

We can set default expression in view object attribute as below
----------------------------------------------------------------

adf.context.securityContext.getUserPrincipal().getName()
or
adf.context.securityContext.getUserName()

Java
-------------------
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 _user = secCntx.getUserName();

How to get Logged in User ID in Application Module ?

String userName = this.getUserPrincipalName();

How to get Logged in User Roles  in Application Module ?

    List userRoles =
      Arrays.asList(ADFContext.getCurrent().getSecurityContext().getUserRoles());

1 comment:

  1. how to reset the password for the logged in user using java code ?

    ReplyDelete