RE: How to give ASSIGN_MEMBERS permission to guest user

pradip choudhari, modified 6 Years ago. Junior Member Posts: 59 Join Date: 5/10/19 Recent Posts
I dropped one portlet in public page , where guest user submit his tokenId  after we show him his details and after confirmation , when he submit that details we create his account in Organisation . But his role is guest user so always we are getting  User 20120 must have ASSIGN_MEMBERS permission for com.liferay.portal.kernel.model.Organization 296207 exception , so how can we give ASSIGN_MEMBERS permission to guest user 
thumbnail
Christoph Rabel, modified 6 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
I honestly don't think what you are trying to accomplish here.
Please paste some code and show us, what fails. Please also tell us, which Liferay version you are using.
pradip choudhari, modified 6 Years ago. Junior Member Posts: 59 Join Date: 5/10/19 Recent Posts
Hello Christoph Rabel
thanks for quick reply.
I am using Liferay 7
I am saving User record in 1 custom table 
for each user I am sending 1 unique Id (tokenId) to his email
so , when he check his email and in that he click url 
so he will came to public page of my site ..after we will show him his details like his name,his email,his phone,his role (e.g faculty,Student..)
after checking his information when he submit details then only we are creating his account in User_ table 
so that time I am getting always exception
thumbnail
Olaf Kock, modified 6 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
pradip choudhari:

...after checking his information when he submit details then only we are creating his account in User_ table 
so that time I am getting always exception
I'm assuming (just to be sure) that you're creating this account through the proper API, not in the table directly.
An important part of Christoph's answer was the question for code: It's so much easier to point out issues when we talk about specific code. But it's good to have your usecase here as well.
I'm assuming that you're implementing this all in your custom portlet. Most likely you're using a remote service (where the class name ends in *Service but not in *LocalService): These are permission checked, thus the anonymous user would need to have permission to use the API in the way that you intend. However, this is a really bad idea, as part of the API is also available remotely - and especially the remote API.
In your custom code, you may do the permission check (against the token) yourself, then invoke the *LocalService. LocalServices in Liferay won't check permissions, but can only be invoked from within the same virtual machine - as is the case with your custom portlet.
pradip choudhari, modified 6 Years ago. Junior Member Posts: 59 Join Date: 5/10/19 Recent Posts
Hello Sir for better understanding , I am attaching image .
and i am explaining my schenerio is ,I am having all User details that details I am showing as like below image .so when he click confirm that time using action req. I am submitting his all information and I am calling UserServiceUtil.addUserWithWorkflow() method to creating his account  and  storing records in User_  table
thumbnail
Olaf Kock, modified 6 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
pradip choudhari:

UserServiceUtil.addUserWithWorkflow()
That's what I was talking about: First of all: You should prefer to use UserService directly (e.g. through OSGi), and no longer through UserServiceUtil starting in Liferay 7.
However, UserService is the remote service, with permission checks. The one that led to your question "how do I grant an unauthenticated user the permission to assign members" (or, in this case, to create user accounts): You don't.
Instead, you'll do the permission check yourself (I'm assuming you already do), then go to UserLocalService, which doesn't check permissions.
pradip choudhari, modified 6 Years ago. Junior Member Posts: 59 Join Date: 5/10/19 Recent Posts
Thanks Olaf Kock 
UserLocalServiceUtil worked for me ..