Populate User From Ldap Without Login in Django

一世执手 提交于 2019-12-06 15:04:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!