0

We are using SharePoint groups to define roles in a custom application. One requirement is to get the groups which the current user is in.

I can of course use the User.Groups property but this only returns groups where the user is directly assigned to the group.

I would like to find the groups where the user is indirectly assigned to the group.

Example

I add "contoso\domain users" to the "Visitors" group.

If I then check User.Groups then the "Visitors" group is not returned.

Which query can I execute which WILL return that group? (along with all of the other groups the user is a member of).

Martin Hatch
  • 1,303
  • 3
  • 13
  • 26

1 Answers1

1

SharePoint will not give you that information. You will need to query the directory provider yourself.

System.DirectoryServices.DirectoryEntry is your salvation. Kirk has a post that can help: http://blogs.msdn.com/b/kaevans/archive/2011/07/04/querying-active-directory.aspx

Or, call Brett and get DeliverPoint. ;)

Paul Schaeflein
  • 5,048
  • 1
  • 20
  • 29
  • Ok, and I suppose it is the same for FBA roles? – Martin Hatch Mar 27 '14 at 13:58
  • One noddy solution ... create a Custom List with list item uniquely permissioned to each group then do an AssignedTo = [Me] query :D – Martin Hatch Mar 27 '14 at 13:59
  • Yup, if the group is managed outside of SharePoint, then you need to query that provider yourself. I do like your list solution, but probably a bunch of administrative overhead when groups are added/deleted... – Paul Schaeflein Mar 27 '14 at 14:01
  • We're managing group creation automatically in code anyway, so might be the easiest solution overall – Martin Hatch Mar 27 '14 at 14:16