I'd like to create lots of users to the system (maybe importing a CSV file or using API). If there's an add-on or we should do it via SSH?
Also, it would be better to assign the users right to the file, so once we create (or import) the users it would in their right place.
I have read something that I can users (like a loop) that in SSH, does anybody know about that how it works?
I'd avoid the Python script in the ZMI. It's a very old way to work.
You can use an add-on or if you are of the 'I prefer to do it myself' persuasion, you can write an external python script
Start a test installation with a copy of your real site in debug mode (bin/instance). Of if you have setup your test site with Ansible use bin/client_reserved; then experiment with the plone api:
plone_daemon@ploneprod2:/usr/local/plone-5.1-latest/ploneprod$ bin/client_reserved debug
Starting debugger (the name "app" is bound to the top-level Zope object)
>>> plone=app.Plone
>>> from zope.component.hooks import setSite
>>> setSite(plone)
>>> from plone import api
>>> prop = dict(fullname='ali khansari', location='Somewhere',)
>>> user = api.user.create(email='ali@nowhere.org', username='ali', password='1234', properties=prop)
>>> api.user.grant_roles(username='ali', roles=['Members'])
>>> import transaction
>>> transaction.commit()
Then when you have your code working with csv handling and everything create a .py file and execute it like that:
plone_daemon@ploneprod2:/usr/local/plone-5.1-latest/ploneprod$ bin/client_reserved run ~/addusr.py
plone_daemon@ploneprod2:/usr/local/plone-5.1-latest/ploneprod$