-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1dea70a
commit 25b475c
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django_auth_ldap.backend import LDAPBackend | ||
from django.conf import settings | ||
from django.contrib.auth.models import Group | ||
|
||
class StaffLDAPBackend(LDAPBackend): | ||
|
||
def get_or_create_user(self, username, ldap_user): | ||
staff_group_name = getattr(settings, 'STAFF_GROUP_NAME', 'Staff') | ||
|
||
user, created = super(StaffLDAPBackend, self).get_or_create_user(username, ldap_user) | ||
if created: | ||
try: | ||
user.groups.add(Group.objects.get(name=staff_group_name)) | ||
except Group.DoesNotExist: | ||
pass | ||
|
||
user.is_staff = True | ||
user.save() | ||
return (user, created) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
Django==1.3.1 | ||
PIL | ||
PIL==1.1.7 | ||
django-auth-ldap==1.0.12 | ||
python-ldap==2.4.3 |