Get Distribution groups for Folder

  • 1
  • Problem
  • Updated 3 years ago
How to get All distribution groups associated with One Folder. Using c#.net API
Photo of Dipankar Chattoraj

Dipankar Chattoraj

  • 6 Posts
  • 0 Reply Likes

Posted 3 years ago

  • 1
Photo of Kyle Stittleburg

Kyle Stittleburg

  • 72 Posts
  • 11 Reply Likes
Here's an example using the .NET SDK to accomplish this:

var myFolderUrl = sfClient.Items.GetAlias("fo7e5c7a-1b37-41c4-938c-7bdaf4eee666");
var groupsOnMyFolderIncludingSuperUserGroup = sfClient.AccessControls.GetByItem(myFolderUrl).Execute().Feed.Where(x => x.Principal is Group).ToList();
var groupsOnMyFolderExcludingSuperUserGroup = sfClient.AccessControls.GetByItem(myFolderUrl).Execute().Feed.Where(x => x.Principal is Group && !x.Principal.Id.StartsWith("gs")).ToList();

If you have the "Super User" group enabled you'll always see it get returned. If you want to exclude it, a quick way is to filter out the group that starts with "gs" which is always the super user group.