Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetSiteCollectionAdminsAsync does not consistently work for Groupified sites #1307

Closed
1 task done
plamber opened this issue Oct 27, 2023 · 6 comments · Fixed by #1323
Closed
1 task done

SetSiteCollectionAdminsAsync does not consistently work for Groupified sites #1307

plamber opened this issue Oct 27, 2023 · 6 comments · Fixed by #1323
Assignees
Labels
area:admin 📜 Admin library related

Comments

@plamber
Copy link
Contributor

plamber commented Oct 27, 2023

Category

  • Bug

Describe the bug

If you try to apply one security group to a Groupified SharePoint site using the sharePointAdminLoginNames parameter, the site collection admin is skipped.

Steps to reproduce

When running the code on a Groupified site, the site collection admin is not applied.

ISiteCollectionManager siteCollectionManager = context.GetSiteCollectionManager();
// add the group as admin
string groupClaim = $"c:0t.c|tenant|{securityGroupId}";
List<String> groupAdmin = new()
{
    groupClaim
};
await siteCollectionManager.SetSiteCollectionAdminsAsync(context.Uri, groupAdmin);

Expected behavior

The first entry is not skipped

Environment details (development & target environment)

Latest official SDK version

Additional context

Seems that there is a loop that skips the first application of a Group. A workaround is assigning the group twice.

ISiteCollectionManager siteCollectionManager = context.GetSiteCollectionManager();
// add the group as admin
string groupClaim = $"c:0t.c|tenant|{securityGroupId}";
List<String> groupAdmin = new()
{
    groupClaim,
    groupClaim
};
await siteCollectionManager.SetSiteCollectionAdminsAsync(context.Uri, groupAdmin);

Thank you for your help

@mloitzl
Copy link
Contributor

mloitzl commented Oct 31, 2023

@plamber @jansenbe I'll have a look into this, since I worked on that part in the past

@plamber
Copy link
Contributor Author

plamber commented Oct 31, 2023

Hi @mloitzl,
thank you.

Br,
Patrick

@jansenbe
Copy link
Contributor

jansenbe commented Nov 9, 2023

That would be great @mloitzl :-)

@jansenbe jansenbe added the area:admin 📜 Admin library related label Nov 9, 2023
@mloitzl
Copy link
Contributor

mloitzl commented Nov 14, 2023

@plamber A quick update

A workaround would be to pass null as the first group admin:

ISiteCollectionManager siteCollectionManager = context.GetSiteCollectionManager();
// add the group as admin
string groupClaim = $"c:0t.c|tenant|{securityGroupId}";
List<String> groupAdmin = new()
{
    null,
    groupClaim
};
await siteCollectionManager.SetSiteCollectionAdminsAsync(context.Uri, groupAdmin);

But anyways, SetSiteCollectionAdmins doesn't handle group connected sites consistently.

@jansenbe I will try to figure out a fix.

@plamber
Copy link
Contributor Author

plamber commented Nov 14, 2023

Hi @mloitzl,
your suggestion for a workaround is definitely better than mine. Thank you for sharing.

Best regards,
Patrick

@mloitzl
Copy link
Contributor

mloitzl commented Nov 24, 2023

Hi @jansenbe and @plamber,

I created #1323

It also contains a new unit test SetSiteCollectionAdminsGroupifiedSiteAddOnly_Async that should cover the issue.

Have a nice weekend! :-)

Martin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:admin 📜 Admin library related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants