0

I'm using the REST API to create a site in SharePoint Online and add an AAD security group to the site member group. When one of the AAD group members tries to access the site it displays the access request page. If the user logs out of O365 and logs back in they are able to access the site.

My basic steps are:

  1. Create site _api/SPSiteManager/create
  2. Create AAD security group and add members
  3. Wait for AAD group to be synced to SharePoint
  4. Add AAD group to site member group _api/web/sitegroups(<id>)/users

Is there a step that would fix this issue? I'm somewhat restricted in what I can use (no javascript, no powershell)

4
  • Is it happening for all members of AD group or just one particular user account? Commented Oct 6, 2022 at 4:36
  • This affects all members Commented Oct 6, 2022 at 16:19
  • Did you use ensureUser before adding AD group to SP group? Can you share code you used if possible? Commented Oct 7, 2022 at 2:20
  • ensureUser makes no difference vs not having it. I'm fairly certain Paul is correct. I just now need to refresh the users' claims somehow. Commented Oct 7, 2022 at 19:02

2 Answers 2

0

I believe this is the expected behavior for AAD groups and SharePoint, due to a user's claims/token caching. As I understand it, it can take 8 hours before the user can access the site, unless of course they logout/login which refreshes their claims.

1
  • This was my hunch as well. I'm still hoping there is something that I can do, either shorten the time for the token to be refreshed or detect when it is refreshed. Commented Oct 6, 2022 at 16:24
0

You can try to add Azure AD security Group into the SPO Site group using powershell

Add-PnPGroupMember -LoginName <Azure AD Group Name> -Group "<Group Name>"

You can refer to this article for more details

https://techpress.net/add-azure-ad-group-to-sharepoint-site-and-configure-site-permissions/#:~:text=Configure%20Sharepoint%20Site%20Permissions,-Login%20on%20the&text=Click%20on%20the%20Settings%20Cog,the%20AD%20Security%20Group%20created.

1
  • I would absolutely love to use PnP.Powershell but it is not an option in the environment I'm running my script in. Commented Oct 6, 2022 at 19:15

Your Answer

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

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