Changeset 2750

Show
Ignore:
Timestamp:
02/23/06 14:19:06 (19 years ago)
Author:
jerome
Message:

Added code to remove an user from an users group in the LDAP backend.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/ldapstorage.py

    r2749 r2750  
    10301030    def delUserFromGroup(self, user, group) :     
    10311031        """Removes an user from a group.""" 
    1032         raise "Not Implemented !" # TODO !!! 
     1032        if user.Name not in [u.Name for u in self.getGroupMembers(group)] : 
     1033            result = self.doSearch("objectClass=pykotaGroup", None, base=group.ident, scope=ldap.SCOPE_BASE) 
     1034            if result : 
     1035                fields = result[0][1] 
     1036                if not fields.has_key(self.info["groupmembers"]) : 
     1037                    fields[self.info["groupmembers"]] = [] 
     1038                try :     
     1039                    fields[self.info["groupmembers"]].remove(self.userCharsetToDatabase(user.Name)) 
     1040                except ValueError : 
     1041                    pass # TODO : Strange, shouldn't it be there ? 
     1042                else : 
     1043                    self.doModify(group.ident, fields) 
     1044                    group.Members.remove(user) 
    10331045                 
    10341046    def addUserPQuota(self, upq) :