Closed gpzope closed 2 years ago
The API documentation at https://productspluggableauthservice.readthedocs.io shows the available methods. Specifically, the user folder has a searchUsers
method that you can use, see https://productspluggableauthservice.readthedocs.io/en/latest/api/userfolder.html#Products.PluggableAuthService.interfaces.authservice.IPluggableAuthService.searchUsers. If you call searchUsers
with no input you will get a sequence of dictionaries where each dictionary contains information about a user. To emulate what getUserNames
does you can pull the value for the key login
from each of these dictionaries, like so:
logins = [x['login'] for x in self.acl_users.searchUsers()]
Question has been answered and no further feedback received, closing.
Jens, thanks for your help on PAS. I do have one more question. I'm trying to write a python script to change a user password. I'm using this method, but so far I don't have any success. It doesn't return any error and it doesn't do anything. What am I doing wrong?
request = context.REQUEST response = request.response login = 'Myuserlogin' new_password = 'mynewpassword' context.acl_users.updateCredentials(request, response, login, new_password)
Thanks again, Giampiero
gpzope wrote at 2022-1-26 09:53 -0800:
Jens, thanks for your help on PAS. I do have one more question. I'm trying to write a python script to change a user password. I'm using this method, but so far I don't have any success. It doesn't return any error and it doesn't do anything. What am I doing wrong?
request = context.REQUEST response = request.response login = 'Myuserlogin' new_password = 'mynewpassword' context.acl_users.updateCredentials(request, response, login, new_password)
Please read the PAS interfaces carefully:
updateCredentials
belongs to the interface ICredentialsUpdatePlugin
.
Its docstring says:
Callback: user has changed her password.
This interface is not responsible for the actual password change,
it is used after a successful password change event.
This means that updateCredentials
is not designed to change the password
but to give other components the chance to adapt to a password change.
To change the password of a user, use a method of its user source.
For the standard ZODBUserManager
this would be updateUserPassword
.
Other user sources may use a different method.
Thanks Dieter,
I did: context.acl_users.ZODBUserManager.manage_updateUserPassword(userlogin,new_password,new_password) and it worked as espected.
What is the difference, if any, between 'manage_updateUserPassword' and 'updateUserPassword' as you suggested?
Thanks again.
Hi, I'm new to PAS and I was just wondering if there is in PAS an equivalent to context.acl_users.getUserNames(). I'm not sure if this is the right place to ask this type of questions.
Thank You