<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "../../Reference_Guide.ent">
%BOOK_ENTITIES;
]>
<section id="sect-Reference_Guide-Accessing_User_Profile">
	<title>Access User Profile</title>
	<para>
		The following code retrieves the details for a logged-in user:
	</para>
	
<programlisting language="java">// Alternative context: WebuiRequestContext context = WebuiRequestContext.getCurrentInstance() ;
PortalRequestContext context = PortalRequestContext.getCurrentInstance() ;
// Get the id of the user logged
String userId = context.getRemoteUser();
// Request the information from OrganizationService:
OrganizationService orgService = getApplicationComponent(OrganizationService.class) ;
if (userId != null)
  {
  User user = orgService.getUserHandler().findUserByName(userId) ;
  if (user != null)
  {
    String firstName = user.getFirstName();
    String lastName = user.getLastName();
    String email = user.getEmail();
  }
}
</programlisting>
	<para>
		Below are two alternatives for retrieving the Organization Service:
	</para>
	<orderedlist>
		<listitem>
			
<programlisting language="java">OrganizationService service = (OrganizationService)
   ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(OrganizationService.class);
</programlisting>
		</listitem>
		<listitem>
			
<programlisting language="java">OrganizationService service = (OrganizationService)
   PortalContainer.getInstance().getComponentInstanceOfType(OrganizationService.class);
</programlisting>
		</listitem>
	</orderedlist>
    <para>
	<prompt>
		<emphasis role="bold">See also</emphasis>
	</prompt>
</para>

		<itemizedlist>
           <listitem>
               <para><link linkend="sect-Reference_Guide-Password-encryption">Password Encryption</link></para>
           </listitem>
           <listitem>
               <para><link linkend="sect-Reference_Guide-Predefined_User_Configuration">Predefined User Configuration</link></para>
           </listitem>
           <listitem>
               <para><link linkend="sect-Reference_Guide-Authentication_Token_Configuration">Authentication Token Configuration</link></para>
           </listitem>
           <listitem>
               <para><link linkend="sect-Reference_Guide-PicketLink_IDM_integration">PicketLink IDM integration</link></para>
           </listitem>
           <listitem>
               <para><link linkend="sect-Reference_Guide-APIs-Organization_API">Organization API</link></para>
           </listitem>
		    <listitem>
               <para><link linkend="chap-Reference_Guide-SSO_Single_Sign_On">Single-Sign-On (SSO)</link></para>
           </listitem>
       </itemizedlist>
</section>


