Index: trac/perm.py
===================================================================
--- trac/perm.py	(revision 5848)
+++ trac/perm.py	(working copy)
@@ -155,6 +155,18 @@
         cursor = db.cursor()
         groups = permissions
         users = set([u[0] for u in self.env.get_known_users()])
+        
+        # Collect the implicit groups and their members. This too could use a
+        # more efficient API
+        implicit_groups = {}
+        for provider in self.group_providers:
+            for username in users:
+                for groupname in provider.get_permission_groups(username):
+                    try:
+                        implicit_groups[groupname].add(username)
+                    except KeyError:
+                        implicit_groups[groupname] = set(username)
+            
         result = set()
 
         # First iteration finds all users and groups that have any of the
@@ -168,6 +180,10 @@
                            % (', '.join(['%s'] * len(groups))), groups)
             groups = []
             for username, nummembers in cursor:
+                if username in implicit_groups:
+                    # A group with members provided by group_providers has
+                    # the necessary permissions set so add all its members.
+                    result.update(implicit_groups[username])
                 if username in users:
                     result.add(username)
                 elif nummembers:

