How can I fetch the existing table data in aportlet - liferay

I am trying to create the user by site admin so I have created a portlet which has basic user details form and in the action class I called the UserLocalServiceUtil.adduser(). Now the values are inserting into the DB in USER_. Now I want to display the list of created users by only site admin how can I do that? I have the following queries.
1) How can I fetch the values from USER_ in my portlet. Do I need to create the service builder OR are there API methods to fetch the values from the USER_ table?
2) I want to display only the users list which is created by site admin in my portlet. I don't want to display the whole company list of users. So How can I achieve this?
Suggest me any references or guidelines to do this.
Your help will be very much appreciated.

For Q1 :
http://cdn.docs.liferay.com/portal/6.1/javadocs/com/liferay/portal/service/UserLocalServiceUtil.html#getUsers(int, int)
This might help you. You don't need service builder for that. Just create a simple Liferay MVC portlet and call the relevant methods.
for Q2 : I don't think this would be possible by API methods. What you can do is to set an expando variable for user at time of creation by site-admin. And # time of fetching users, you can cross-check the value of that field manually.
EDIT :
One more point for suggestion : Never create user with Site-Admin role for user creation. This role is supposed to manage site & user assignment to the site. You can use more appropriate role i.e. Org-Admin rather than site-Admin.
How to set an expando variable while adding the user?
Liferay provides Expando API interface, which you can use while creation of user in your portlet. refer following links Developing with Expando, Liferay Expando API
I hope this would be helpful to you.

Related

Add new fields to create_account.jsp without custom fields functionality in Liferay

I want to add 15 new fields to my user account creation page in Liferay. How it is possible other than custom fields, expando tables? Because I know how to use custom fields. I have more fields so it will be difficult to manage. Through hook I want to add more fields to account creation page.
Fields are related to user.
Create one selectbox that will have list of organizations available in my application.
Create one selectbox that will have list of roles available in my application.
onclicking of save button that should redirect to 3rd party payment gateway. Once paid amount it will create account for that user.
After paid amount all the above fields need to add under extra table with related columns and maps to the user_ table with userId as a primary key.
assign that organization to the user which is selected above and similar for role also.
I am using Liferay 6.2. Please let me know if any one have any ideas!
Learn Java. A modification of the platform to the extent that you're mentioning won't work without knowing Java. You'll introduce all kinds of issues in your system.
Then there are two options:
Just implement a custom portlet that takes all the values that you want, saves them where you want and queues them in your payment system. Disable Liferay's "do-it-yourself-signup" and place your own links to the "create account" portlet. This will be easiest to maintain
Alternatively, override Liferay's JSP that's used for the "create account" UI as well as the action that's handling the data. The default implementation would save everything in Liferay's database - including custom fields. As you implement it yourself, you can do whatever you want with this data.

NodeJs : Liferay api to fetch the "custom field" created for Role

According to my requirement in Liferay, I have created custom fields for roles and assigned it to a user. My goal is to call the JSONWS API and get these custom fields using NodeJS. I am not able to decide which API I should call.
This Url is having APIs: http://www.liferay.com/api/jsonws
I will appreciate for any kind of help.
Regards
AFAIK there is no options to access the expando value via exposed webserveices.
Probably what you can do is that, create a custom portlet, add a dummy entity in the service builder and in that expose a method for web service. In that method call the role API and expando API , and return the result you want.
Custom Fields are called "Expando" in the API and are modeled like virtual tables. The functionality that's exposed through webservices is ExpandoColumn and ExpandoValue. Probably the best way to figure out the parameters to give is to look at the matching database tables. Careful: You should only ever read the database and not be tempted to write to it.
I hate giving the advice to go to the database, but this is probably the quickest - at least for my explanation :)
Finally, I got a genuine solution without hitting database directly. JSONWS is having api :
/portal.expandovalue/get-data
Which helped me to get attributes assigned to a particular role.
The above API needs 5 parameters to be passed.
companyId: whaterver the companyId assigned for your liferay.
className: It depends upon, we created attribute for role or user
com.liferay.portal.model.Role or com.liferay.portal.model.User
tableName: CUSTOM_FIELDS
columnName: It is the same name you given for attribute
classPK: It is nothing but your role or user ID for which you have created Attribute.
In case you are getting "java.lang.NullPointerException" when using #user3771220 solution, try com.liferay.portal.kernel.model.User

Query the Manager object from AD in Sharepoint

We're trying to set up a workflow for approval of an item in a list in Sharepoint 2010, where whenever a user creates an item in the list, it automatically routes to their manager for approval before being added to the queue of work items. We'd also like to go a step further and recursively query up the heirarchy until we reach a user with a specific "Job Title".
We use the "manager" attribute and "title" attribute in user profiles so we should be able to poll all this info from AD.
Anyone have any experience or thought as in how to accomplish this task?
Thanks for the help.
+1 to what Patricker suggested with respect to user profile traversal. For AD Query assuming you are using an MS product for AD, create an LDAP Query.
You should be able to figure out lot of tools as well to build LDAP queries. My personal favorite is Search Using Active Directory Users and Computers
To execute LDAP queries via .Net you would use classes in System.DirectoryService namespace

Liferay - Authentication without populating liferay db

Again, Do we have any possible solution that avoid populating liferay db with user information for authentication using extending methods/custom implementation/hooks/plugins/extensions?
Regards
Vishal G
There's no way to avoid creating a user in the Liferay database. You can though create a dummy user that all users use or a dummy user for every user depending on your needs
It is generally not desirable to share accounts as you cannot benefit from all functionality regarding groups, personalization, ... This is basically why one would install a portal.
To create users you can use Liferay's services.
If authorization is not your concern, it is possible to override the authenitaction mechanism with a variety of methods. THe authentication pipeline might be a good starting point.
http://www.liferay.com/documentation/liferay-portal/6.1/user-guide/-/ai/authentication-pipeline
Good luck!
You can create a Liferay Hook to Authenticate using your custimization.
override the following jsp page.
/html/portlet/login/login.jsp
Or you can create your own login portlet. No need to populate all users in db.
Just findUserById().
Dont forget to mention this change in portal-ext.properties file. You will need to specify custom Login portlet id.

Can SharePoint's Select People and Groups dialog box's Title and Department fields be customized with a custom membership provider?

I have created a custom membership provider for a SharePoint application but would like to populate the Title and Department columns for the MembershipUsers that are displayed with data from my user repository.
Is this possible? How can it be done?
I don't see anything in the System.Web.Security.MembershipUser class that could store this information. How does the Windows AD MembershipProvider have a different Display Name than the Account Name? Are some of these values coming from someplace else?
What happens in the AD is that, SharePoint runs the User Profile Sync Job that will pull all the required information from AD and updated the SharePoint UserProfile DB which In turn pushes to Each of the Site. Whereas in the case of the Custom Membership we don't have a direct option to update the Profile Information.
One method you can do is to update those information using code.There are two options you can update the User Profile information in the SSP so that it will be displayed in all the Site Collection or to Update the SPWeb.SiteUserInfo List. Please refer these link1 , link2 on how to do that. In case you want to update in SiteUserInfo list it is just another list just search for Item based on the user account name and update that item.

Resources