def is_member(self, ldap_user, group_dn):
try:<EOL><INDENT>user_uid = ldap_user.attrs['<STR_LIT>'][<NUM_LIT:0>]<EOL>try:<EOL><INDENT>is_member = ldap_user.connection.compare_s(force_str(group_dn), '<STR_LIT>', force_str(user_uid))<EOL><DEDENT>except (ldap.UNDEFINED_TYPE, ldap.NO_SUCH_ATTRIBUTE):<EOL><INDENT>is_member = False<EOL><DEDENT>if not is_member:<EOL><INDENT>try:<EOL><INDENT>user_gid = ldap_user.attrs['<STR_LIT>'][<NUM_LIT:0>]<EOL>is_member = ldap_user.connection.compare_s(force_str(group_dn), '<STR_LIT>', force_str(user_gid))<EOL><DEDENT>except (ldap.UNDEFINED_TYPE, ldap.NO_SUCH_ATTRIBUTE):<EOL><INDENT>is_member = False<EOL><DEDENT><DEDENT><DEDENT>except (KeyError, IndexError):<EOL><INDENT>is_member = False<EOL><DEDENT>return is_member<EOL>
Returns True if the group is the user's primary group or if the user is
listed in the group's memberUid attribute.