Browse Source

Remove useless custom.CoinPosixGroupType (because official PosixGroupType now work)

Fabs 11 years ago
parent
commit
5fb0928e97
3 changed files with 3 additions and 67 deletions
  1. 3 4
      coin/settings.py
  2. 0 1
      custom/__init__.py
  3. 0 62
      custom/coin_posix_group_type.py

+ 3 - 4
coin/settings.py

@@ -1,9 +1,8 @@
 # -*- coding: utf-8 -*-
 import os
 import ldap
-from django_auth_ldap.config import LDAPSearch, GroupOfNamesType
-#                                   , PosixGroupType
-from custom.coin_posix_group_type import CoinPosixGroupType
+from django_auth_ldap.config import LDAPSearch, PosixGroupType
+# from custom.coin_posix_group_type import CoinPosixGroupType
 
 # Django settings for coin project.
 
@@ -197,7 +196,7 @@ AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
     "(objectClass=posixGroup)"
 )
 
-AUTH_LDAP_GROUP_TYPE = CoinPosixGroupType()
+AUTH_LDAP_GROUP_TYPE = PosixGroupType()
 
 # AUTH_LDAP_REQUIRE_GROUP = "cn=admin,ou=groups,o=ILLYSE,"
 #                           "l=Villeurbanne,st=RHA,c=FR"

+ 0 - 1
custom/__init__.py

@@ -1 +0,0 @@
-

+ 0 - 62
custom/coin_posix_group_type.py

@@ -1,62 +0,0 @@
-import ldap
-from django_auth_ldap.config import LDAPGroupType
-
-class CoinPosixGroupType(LDAPGroupType):
-
-    """
-    An LDAPGroupType subclass that handles groups of class posixGroup.
-    """
-    def user_groups(self, ldap_user, group_search):
-        """
-        Searches for any group that is either the user's primary or contains the
-        user as a member.
-        """
-        groups = []
-
-        try:
-
-            user_uid = ldap_user.attrs['uid'][0]
-            if ('gidNumber') in ldap_user.attrs:
-                user_gid = ldap_user.attrs['gidNumber'][0]
-                filterstr = u'(|(gidNumber=%s)(memberUid=%s))' % (
-                    self.ldap.filter.escape_filter_chars(user_gid),
-                    self.ldap.filter.escape_filter_chars(user_uid)
-                )
-            else:
-                filterstr = u'(memberUid=%s)' % (
-                    self.ldap.filter.escape_filter_chars(user_uid)
-                )
-
-
-            search = group_search.search_with_additional_term_string(filterstr)
-            groups = search.execute(ldap_user.connection)
-        except (KeyError, IndexError):
-            pass
-
-        return groups
-
-    def is_member(self, ldap_user, group_dn):
-        """
-        Returns True if the group is the user's primary group or if the user is
-        listed in the group's memberUid attribute.
-        """
-        try:
-
-            user_uid = ldap_user.attrs['uid'][0]
-
-            try:
-                is_member = ldap_user.connection.compare_s(group_dn.encode('utf-8'), 'memberUid', user_uid.encode('utf-8'))
-            except self.ldap.NO_SUCH_ATTRIBUTE:
-                is_member = False
-
-            if not is_member:
-                try:
-                    user_gid = ldap_user.attrs['gidNumber'][0]
-                    is_member = ldap_user.connection.compare_s(group_dn.encode('utf-8'), 'gidNumber', user_gid.encode('utf-8'))
-                except self.ldap.NO_SUCH_ATTRIBUTE:
-                    is_member = False
-        except (KeyError, IndexError):
-            is_member = False
-
-        return is_member
-