Thursday, 10 October 2013

How to get Custom Field value in Liferay using liferay API?

This code is done for the Expando of User Model (UserExpando) and the custom filed "userCity"



//////////////////////////////

LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
               
                long companyId = liferayFacesContext.getCompanyId();
               
                User user = liferayFacesContext.getUser();
                System.out.println("User info "+user.getUserId()+" --- "+user.getFirstName()+" ---- "+user.getEmailAddress());
                Locale locale = liferayFacesContext.getLocale();
                ExpandoValue val=null;
                ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getDefaultTable(companyId,User.class.getName());
                long expandoTableId=expandoTable.getTableId();
                ExpandoColumn column = ExpandoColumnLocalServiceUtil.getColumn(expandoTableId, UserExpando.USER_CITY.getName());
                 if (column != null) {
                 val = ExpandoValueLocalServiceUtil.getValue(expandoTableId, column.getColumnId(), user.getUserId());
                   if (val != null) {
                     System.out.println("val====================="+ val);
                   }
                  
                }

/////////////////////////////////

How to get logged In User detail in liferay?

How to get logged In User detail in liferay?

These lines of code will give you the user who is logged in from the LiferayFaces Context.

LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
                
 long companyId = liferayFacesContext.getCompanyId();
                
 User user = liferayFacesContext.getUser();                       //User is an Model of liferay

Wednesday, 27 February 2013

How to change user authentication Type in Liferay ?

 How to change user Authentication/ login Type in Liferay? If i want to use screen name instead of emailAddress
There  are two ways to change login type in liferay
1)
company.security.auth.type=emailAddress
#company.security.auth.type=screenName
#company.security.auth.type=userId

In the above case , screenName and userId are commented out using #

2)
a)Login as Admin
b)go to Control panel
c)Click on the Portal setting in the left panel under portal tab
d)Click on the Authentication link in the right panel
e)Select the desired login type from the drop down(How do users authenticate? ) under the General tab.

LDAP connection Read timeout in Liferay

LDAP connection Read timeout in Liferay

Put this lines in portal-ext.properties file to avoid this problem

ldap.connection.com.sun.jndi.ldap.connect.timeout=1000
ldap.connection.com.sun.jndi.ldap.read.timeout=2000


Map Ldap Group with Liferay role

Map Ldap Group with Liferay role


Put the following line into portal-ext.properties file

ldap.import.create.role.per.group=true
layout.show.portlet.access.denied=false

Thursday, 31 January 2013

LDAP Configuration with Liferay   through Control Panel for secured connection


LDAP Configuration with Liferay   through Control Panel for secured connection

  • Import the certifcate of ldap server(for secured connection) into your local Jdk.
  • Login as an admin.Default user admin is test and password is test.
  • Hover on Go to then Control Pannel
  • In control panelm page Click Portal Setting of the left Panel
  • Click Authentication link of the  Right panel
  • Select Screen Name for How do users authenticate?  then save -Optional
  • Now click on the LDAP tab and check Enable
  • Then Click on Add button to Add and Cofigure LDAP server .
  •  e.g as an screen shot below

  • Then click save