Foros de discusión
Deactivate user in liferay programmetically
Mreetunjay Sharma, modificado hace 10 años.
Deactivate user in liferay programmetically
Junior Member Mensajes: 29 Fecha de incorporación: 20/05/13 Mensajes recientes
Hello Everybody,
I have dectivate user in liferay programmetically like:
User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAdd);
user.setStatus(WorkflowConstants.STATUS_INACTIVE);
but when i see user list in Control Panel->Users and Organizations, User is stil showing and he also able to do login in liferay poratl.
so, is there any other way to deactivate user show that user can not be seen in Control Panel->Users and Organizations, and also not able to do login.
Thanks & Regards,
Mreetunjay Sharma
I have dectivate user in liferay programmetically like:
User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAdd);
user.setStatus(WorkflowConstants.STATUS_INACTIVE);
but when i see user list in Control Panel->Users and Organizations, User is stil showing and he also able to do login in liferay poratl.
so, is there any other way to deactivate user show that user can not be seen in Control Panel->Users and Organizations, and also not able to do login.
Thanks & Regards,
Mreetunjay Sharma
Jitendra Rajput, modificado hace 10 años.
RE: Deactivate user in liferay programmetically
Liferay Master Mensajes: 875 Fecha de incorporación: 7/01/11 Mensajes recientes
Even in OOB you will see same way they are deactivating user. Please cross check.
HTH,
Jitendra
http://itsliferay.blogspot.in/
if (cmd.equals(Constants.DEACTIVATE)) {
status = WorkflowConstants.STATUS_INACTIVE;
}
UserServiceUtil.updateStatus(deleteUserId, status);
HTH,
Jitendra
http://itsliferay.blogspot.in/
Mreetunjay Sharma, modificado hace 10 años.
RE: Deactivate user in liferay programmetically
Junior Member Mensajes: 29 Fecha de incorporación: 20/05/13 Mensajes recientes
Thanks Jitendra for your reply.
will You please tell me what is cmd, and how can I get cmd ?
shall I get it like :
String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
any other way to delete users in liferay ??
will You please tell me what is cmd, and how can I get cmd ?
shall I get it like :
String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
any other way to delete users in liferay ??
Pankaj Kathiriya, modificado hace 10 años.
RE: Deactivate user in liferay programmetically
Liferay Master Mensajes: 722 Fecha de incorporación: 5/08/10 Mensajes recientes
Well, cmd is parameter passed to controller, it can be add,update,delete,deactivate.
To delete the user you can call method UserServiceUtil.deleteUser(userId);
For Deactivate user refer to code given by Jitendra
To delete the user you can call method UserServiceUtil.deleteUser(userId);
For Deactivate user refer to code given by Jitendra
Mreetunjay Sharma, modificado hace 10 años.
RE: Deactivate user in liferay programmetically
Junior Member Mensajes: 29 Fecha de incorporación: 20/05/13 Mensajes recientes
Thank pankaj,
I have done like this
ThemeDisplay themeDisplay=(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
long companyId=themeDisplay.getCompanyId();
User usr = UserLocalServiceUtil.getUserByEmailAddress(companyId, email);
UserServiceUtil.deleteUser(usr.getUserId());
but I am getting exception like :
com.liferay.portal.security.auth.PrincipalException
I have done like this
ThemeDisplay themeDisplay=(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
long companyId=themeDisplay.getCompanyId();
User usr = UserLocalServiceUtil.getUserByEmailAddress(companyId, email);
UserServiceUtil.deleteUser(usr.getUserId());
but I am getting exception like :
com.liferay.portal.security.auth.PrincipalException
Sushil Patidar, modificado hace 10 años.
RE: Deactivate user in liferay programmetically
Expert Mensajes: 467 Fecha de incorporación: 31/10/11 Mensajes recientesMreetunjay Sharma:
Thank pankaj,
I have done like this
ThemeDisplay themeDisplay=(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
long companyId=themeDisplay.getCompanyId();
User usr = UserLocalServiceUtil.getUserByEmailAddress(companyId, email);
UserServiceUtil.deleteUser(usr.getUserId());
but I am getting exception like :
com.liferay.portal.security.auth.PrincipalException
It seems the current user don't have permission to delete user .
Regards
Jitendra Rajput, modificado hace 10 años.
RE: Deactivate user in liferay programmetically
Liferay Master Mensajes: 875 Fecha de incorporación: 7/01/11 Mensajes recientes
No No .. I just copied that code from EditUserAction to give you understanding.
You should only follow 2 lines to deactivate user.
HTH,
Jitendra
http://itsliferay.blogspot.in/
You should only follow 2 lines to deactivate user.
User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAdd);
status = WorkflowConstants.STATUS_INACTIVE;
UserServiceUtil.updateStatus(user.getUserId(), status);
HTH,
Jitendra
http://itsliferay.blogspot.in/
Mreetunjay Sharma, modificado hace 10 años.
RE: Deactivate user in liferay programmetically
Junior Member Mensajes: 29 Fecha de incorporación: 20/05/13 Mensajes recientes
Jitendra,
I have already done like this but I am not sure whether users are being inactive or not. Because users are able to do login.
I think once user will be inactive then can't do login..
I have already done like this but I am not sure whether users are being inactive or not. Because users are able to do login.
I think once user will be inactive then can't do login..
Pankaj Kathiriya, modificado hace 10 años.
RE: Deactivate user in liferay programmetically
Liferay Master Mensajes: 722 Fecha de incorporación: 5/08/10 Mensajes recientes
After deactivation user can do login, but can not see any content. User will be given message[your account is deactivated something like this] instead.
Mreetunjay Sharma, modificado hace 10 años.
RE: Deactivate user in liferay programmetically
Junior Member Mensajes: 29 Fecha de incorporación: 20/05/13 Mensajes recientes
And If I want to delete user from portal(liferay database) permanently then what I nee to do ??
Pankaj Kathiriya, modificado hace 10 años.
RE: Deactivate user in liferay programmetically
Liferay Master Mensajes: 722 Fecha de incorporación: 5/08/10 Mensajes recientesUserLocalServiceUtil.deleteUser(userId);will work.
I-A Kotopoulos, modificado hace 8 años.
RE: Deactivate user in liferay programmetically
Junior Member Mensajes: 44 Fecha de incorporación: 14/01/14 Mensajes recientesPankaj Kathiriya:
UserLocalServiceUtil.deleteUser(userId);will work.
After using this the user still remains in the database table. Is there any difference between UserLocalServiceUtil.deleteUser(Long); and UserLocalServiceUtil.deleteUser(User); ?