Trying to use the populate_user signal to do some custom processing but no effect.
from django.dispatch import receiver
from django_auth_ldap.backend import populate_user, LDAPBackend
@receiver(populate_user, sender=LDAPBackend)
def ldap_auth_handler(user, ldap_user, **kwargs):
"""
Create mailbox and create user with email
"""
print("signal")
User gets populated, log below:
search_s('ou=people,dc=example,dc=com', 2, '(mail=%(user)s)') returned 1 objects: uid=alice,ou=people,dc=example,dc=com DEBUG:django_auth_ldap:search_s('ou=people,dc=example,dc=com', 2, '(mail=%(user)s)') returned 1 objects: uid=alice,ou=people,dc=example,dc=com Creating Django user [email protected] DEBUG:django_auth_ldap:Creating Django user [email protected] Populating Django user [email protected] DEBUG:django_auth_ldap:Populating Django user [email protected]
Sorry didn't read the Django signals documentation properly, need to import the signals module in app_config. Also since I am using custom backend, had to replace it in the signal (not sure it is correct but works):