问题
I'm using django-auth-ldap for auth backend in a Django project. But I have a problem, I can't give any permissions to a user before user once logged in. Because the user object created when user tring login to system.
I want to write a task to populate user from ldap periodically, how I can do that. I can't just login for each unpopulated user since I don't know their passwords.
回答1:
I found out I just can populate user like this:
from django_auth_ldap.backend import LDAPBackend
ldap_backend = LDAPBackend()
ldap_backend.populate_user('username')
来源:https://stackoverflow.com/questions/29562194/populate-user-from-ldap-without-login-in-django