3

I'm attempting to use the .NET Microsoft.Graph SDK to create two groups and add one to the other. The group creation is fine and they show up in the Microsoft Graph Explorer. However, when I attempt to add the group to the other group, I get an error:

Microsoft.Graph.ServiceException
  HResult=0x80131500
  Message=Code: Request_BadRequest
Message: An invalid operation was included in the following modified references: 'members'.

Inner error

  Source=Microsoft.Graph.Core
  StackTrace:
   at Microsoft.Graph.HttpProvider.<SendAsync>d__19.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.BaseRequest.<SendRequestAsync>d__36.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.BaseRequest.<SendAsync>d__31.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at [mycode].cs:line 170

I'm adding the group with the following:

await _serviceClient.Groups[memberGroup.Id]
    .Members
    .References
    .Request()
    .AddAsync(new Group { Id = adminGroup.Id });

Edit These are security groups

Taylor Southwick
  • 1,456
  • 13
  • 14
  • did you manage to resolve this issue? Having the same issue here. – Roy Sep 07 '18 at 08:47
  • 1
    Turned out that the issue is that B2C does not support nested security groups. I ended up modeling it in Cosmos to track parent/child relationships and expanding the groups from B2C with the hierarchy Cosmos defines. Not ideal, but it works – Taylor Southwick Sep 20 '18 at 22:05

2 Answers2

1

Office 365 Groups ("groupTypes": ["Unified"]) don't support "nested" Groups (Adding one Group as Member of another Group). Only Security Groups may contain nested Groups. From the documentation:

You can add only users to Office 365 Groups.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
0

Nested Groups are not supported in Groups so what you are seeing is correct: when adding a Group, you are adding the Group members but not the group itself We cannot nest the security group in O365 too.

If you config your code rightly, you should getting the fllowing tip: "The request is currently not supported."

Seiya Su
  • 1,836
  • 1
  • 7
  • 10
  • Are you saying you cannot nest security groups? If so, can you please link and share the documentation? – Taylor Southwick Aug 07 '18 at 00:37
  • More user are request the nest group feature for O365 group. https://techcommunity.microsoft.com/t5/Office-365-Groups/How-to-manage-O365-Group-membership-through-AD-Security-Groups/td-p/28366 https://office365.uservoice.com/forums/286611-office-365-groups/suggestions/10114956-be-able-to-nest-groups-like-distribution-groups – Seiya Su Aug 07 '18 at 06:06
  • https://techcommunity.microsoft.com/t5/Office-365-Groups/Nested-O365-Groups-are-in-the-works/td-p/18801 – Seiya Su Aug 07 '18 at 07:26
  • Thanks, but I'm not using O365 groups - I'm only using security groups (please see the title of the question and the edit I made at the bottom). The only caveat I see in the documentation is for nested O365, but not nested security groups (which works fine in AD in general) – Taylor Southwick Aug 07 '18 at 16:37
  • Base on my test, the nest security group in O365 cannot done now. Please check the link I provided but not only the text itself. The request contains Group and security group. Graph is get data from azure(So although the group you created is security group but not O365 group, it still have issue now. ) – Seiya Su Aug 08 '18 at 00:10
  • You have pointed:"which works fine in AD in general".But now graph will operate the AAD but oridinary AD. – Seiya Su Aug 08 '18 at 00:12