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).

1 Answer 1

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. ;)

4
  • Ok, and I suppose it is the same for FBA roles? Mar 27, 2014 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 Mar 27, 2014 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... Mar 27, 2014 at 14:01
  • We're managing group creation automatically in code anyway, so might be the easiest solution overall Mar 27, 2014 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.