Profile exists but I get: Django user {user} does not have a profile to populate

481 views
Skip to first unread message

Bret Palsson

unread,
Oct 25, 2011, 9:39:52 AM10/25/11
to django-a...@googlegroups.com
For some reason I cannot get the AUTH_LDAP to populate the profile created when logging in. It can't find it. Here are all the relevant files and out put. At the end I did a query to see if the profile was created, it was. I also deleted the user where it shows it's deleting the user profile and the user.

What am I doing wrong here?

settings.py:
# LDAP AUTH
AUTH_LDAP_START_TLS = False
ldap.set_option( ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER )
AUTH_LDAP_SERVER_URI = "ldaps://ldap"
AUTH_LDAP_BIND_DN = "cn=auth service,cn=config"
AUTH_LDAP_BIND_PASSWORD = "HIDE"
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=NA,dc=EXAMPLE,dc=COM",
ldap.SCOPE_SUBTREE, "(uid=%(user)s)")

AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=NA,dc=EXAMPLE,dc=COM",
ldap.SCOPE_SUBTREE, "(objectClass=posixGroup)"
)

AUTH_LDAP_GROUP_TYPE = MemberDNGroupType(member_attr='uniqueMember', name_attr='cn')

AUTH_LDAP_REQUIRE_GROUP = "cn=emp,ou=Groups,ou=HQ,ou=NA,dc=EXAMPLE,dc=COM"
AUTH_LDAP_ALWAYS_UPDATE_USER = True

AUTH_PROFILE_MODULE = 'directory.account.UserProfile'
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail"
}

AUTH_LDAP_PROFILE_ATTR_MAP = {
"gidNumber": "gidNumber"
}

AUTH_LDAP_USER_FLAGS_BY_GROUP = {
"is_staff": "cn=emp,ou=Groups,ou=HQ,ou=NA,dc=EXAMPLE,dc=COM",
"is_superuser": "cn=Admin,ou=Groups,ou=HQ,ou=NA,dc=EXAMPLE,dc=COM",
}

AUTH_LDAP_FIND_GROUP_PERMS = True

AUTHENTICATION_BACKENDS = (
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)

app/models.py:
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver

class UserProfile(models.Model):
user = models.OneToOneField(User)
gidNumber = models.IntegerField(null=True)

@receiver(post_save, sender=User)
def create_profile(sender, instance, created, **kwargs):
if created:
profile, new = UserProfile.objects.get_or_create(user=instance)

Errors:
[Tue Oct 25 08:25:54 2011] [error] search_s('ou=NA,dc=EXAMPLE,dc=COM', 2, '(uid=bret)') returned 1 objects: uid=bret,OU=Users,OU=HQ,ou=NA,dc=EXAMPLE,dc=COM
[Tue Oct 25 08:25:54 2011] [error] uid=bret,OU=Users,OU=HQ,ou=NA,dc=EXAMPLE,dc=COM is a member of cn=emp,ou=Groups,ou=HQ,ou=NA,dc=EXAMPLE,dc=COM
[Tue Oct 25 08:25:54 2011] [error] Created Django user bret
[Tue Oct 25 08:25:54 2011] [error] Populating Django user bret
[Tue Oct 25 08:25:54 2011] [error] uid=bret,OU=Users,OU=HQ,ou=NA,dc=EXAMPLE,dc=COM is a member of cn=Admin,ou=Groups,ou=HQ,ou=NA,dc=EXAMPLE,dc=COM
[Tue Oct 25 08:25:54 2011] [error] uid=bret,OU=Users,OU=HQ,ou=NA,dc=EXAMPLE,dc=COM is a member of cn=emp,ou=Groups,ou=HQ,ou=NA,dc=EXAMPLE,dc=COM
[Tue Oct 25 08:25:54 2011] [error] Django user bret does not have a profile to populate


Database query:
[root@apps directory]# sqlite3 db/directory.db
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> select * from account_userprofile;
1|4|

If I delete the user:
Are you sure you want to delete the selected user? All of the following objects and their related items will be deleted:

User: bret
User profile: UserProfile object

Peter Sagerson

unread,
Oct 25, 2011, 12:29:30 PM10/25/11
to django-a...@googlegroups.com
Have you confirmed that user.get_profile() works in other contexts? Your setting for AUTH_PROFILE_MODULE looks unusual--I believe it should only have two components (app_label.ModelName).[1]


[1] https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional-information-about-users

Di majo

unread,
May 12, 2024, 2:17:56 PM5/12/24
to django-auth-ldap
MT103/202 DIRECT WIRE TRANSFER
PAYPAL TRANSFER
CASHAPP TRANSFER
ZELLE TRANSFER
LOAN DEAL
TRANSFER WISE
WESTERN UNION TRANSFER
BITCOIN FLASHING
BANK ACCOUNT LOADING/FLASHING
IBAN TO IBAN TRANSFER
MONEYGRAM TRANSFER
IPIP/DTC
SLBC PROVIDER
CREDIT CARD TOP UP
DUMPS/ PINS
SEPA TRANSFER
WIRE TRANSFER
BITCOIN TOP UP
GLOBALPAY INC US
SKRILL USA
UNIONPAY RECEIVER

Thanks.


NOTE; ONLY SERIOUS / RELIABLE RECEIVERS CAN CONTACT.

DM ME ON WHATSAPP
+44 7529 555638

Di majo

unread,
May 12, 2024, 2:19:58 PM5/12/24
to django-auth-ldap
Reply all
Reply to author
Forward
0 new messages