0

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 alice@example.com DEBUG:django_auth_ldap:Creating Django user alice@example.com Populating Django user alice@example.com DEBUG:django_auth_ldap:Populating Django user alice@example.com

sol
  • 15
  • 1
  • 5

1 Answers1

0

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):

@receiver(populate_user, sender=CustomLDAPBackend)
sol
  • 15
  • 1
  • 5