I have tried below one but its not working:
curl -u admin:admin -Frep:disabled=true http://localhost:4502/home/users/t/testuser.rw.html
getting below error message:
javax.jcr.nodetype.ConstraintViolationException: Unable to perform operation. Node is protected.
Solved! Go to Solution.
Hi Aditi,
Have you tried creating a custom servlet and on post request:
@SuppressWarnings("serial") @Component(immediate = true, metatype = false) @Service(value = javax.servlet.Servlet.class) @Properties({ @Property(name = Constants.SERVICE_DESCRIPTION, value = "Custom User Manager"), @Property(name = Constants.SERVICE_VENDOR, value = OsgiServiceProperties.SERVICE_VENDOR), @Property(name = "sling.servlet.selectors", value = { "user" }), @Property(name = "sling.servlet.extensions", value = { "api" }) }) public class UserManagementAPI extends SlingAllMethodsServlet { @Reference private ResolverManager rmanager; @Override protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException { final ResourceResolver resolver = rmanager.getCurrentOrCreateNew().getResolver(); final UserManager userManager = resolver.adaptTo(UserManager.class); final Authorizable authorizable = userManager.get(request.getParameter("userPath")); // the path in the repo where the user account is stored final User user = authorizable.adaptTo(User.class); // adapt authorisable to actual user in order to access disable user.disable("Does not follow compliance regulations..."); // remember to have a reason } }
Peter
Views
Replies
Total Likes
Here is a great community article written by an AEM community member - Yogesh - that talks about how to perform user operations using Curl:
http://www.wemblog.com/2012/03/how-to-do-user-management-using-post.html
Thanks for your reply :)
But there is no command to disable the user .....
Views
Replies
Total Likes
The property rep:disabled is set on an authorizable node (rep:User or rep:Group) that user or group becomes disabled. However this property is protected and you cannot set it directly.Though I am not sure is security API provide that option. You can try with User.setProperty().
Views
Replies
Total Likes
Thanks for the reply :)
I want to do it using curl command, so that i can disable any number of users with less efforts
Views
Replies
Total Likes
Hi Aditi,
Have you tried creating a custom servlet and on post request:
@SuppressWarnings("serial") @Component(immediate = true, metatype = false) @Service(value = javax.servlet.Servlet.class) @Properties({ @Property(name = Constants.SERVICE_DESCRIPTION, value = "Custom User Manager"), @Property(name = Constants.SERVICE_VENDOR, value = OsgiServiceProperties.SERVICE_VENDOR), @Property(name = "sling.servlet.selectors", value = { "user" }), @Property(name = "sling.servlet.extensions", value = { "api" }) }) public class UserManagementAPI extends SlingAllMethodsServlet { @Reference private ResolverManager rmanager; @Override protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException { final ResourceResolver resolver = rmanager.getCurrentOrCreateNew().getResolver(); final UserManager userManager = resolver.adaptTo(UserManager.class); final Authorizable authorizable = userManager.get(request.getParameter("userPath")); // the path in the repo where the user account is stored final User user = authorizable.adaptTo(User.class); // adapt authorisable to actual user in order to access disable user.disable("Does not follow compliance regulations..."); // remember to have a reason } }
Peter
Views
Replies
Total Likes
Views
Likes
Replies
Views
Like
Replies