Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions docs/using-the-sdk/admin-sharepoint-security.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ foreach(var admin in admins)

To set the administrators of a given site collection use the `SetSiteCollectionAdmins` methods. You do not have to have access to the site collection to set it's administrators as these methods depend on tenant APIs that only work for SharePoint administrators. When setting the administrators you'll see a difference between Microsoft 365 group connected site collections and the other site collections:

- For the other site collections you provide a list of login names (e.g. `i:0#.f|membership|[email protected]` or `c:0-.f|rolemanager|spo-grid-all-users/6492ece7-7f5d-4499-8130-50e761e25bd9`). The first one if the list will be set as the primary site collection administrator, the others will be set as secondary site collection administrators
- For Microsoft 365 group connected site collections you do have the same option as for the other site collections with the difference that the primary site collection administrator of group connected sites is never updated. Next to that you can also specify the Azure AD user id's of users you want to grant site collection admin permissions by adding them to the Microsoft 365 group's owners. To stay in sync with with SharePoint Tenant admin center does, when adding a Microsoft 365 group owner the user is also added as a Microsoft 365 group member.
- For the other site collections you provide a list of login names (e.g. `i:0#.f|membership|[email protected]` or `c:0-.f|rolemanager|spo-grid-all-users/6492ece7-7f5d-4499-8130-50e761e25bd9`). The first one of the list will be set as the primary site collection administrator, the others will be set as secondary site collection administrators.
- For Microsoft 365 group connected site collections you do have the same option as for the other site collections with the difference that the primary site collection administrator of group connected sites is never updated. Next to that you can also specify the Azure AD user id's of users you want to grant site collection admin permissions by adding them to the Microsoft 365 group's owners. To stay in sync with what SharePoint Tenant admin center does, when adding a Microsoft 365 group owner the user is also added as a Microsoft 365 group member.

```csharp
// Set the site collection admins for a regular site
Expand All @@ -77,3 +77,35 @@ newGroupOwners.Add(Guid.Parse("3d25e9c4-b20f-443b-ab4d-8ab0668f72ee"));

context.GetSiteCollectionManager().SetSiteCollectionAdmins(new Uri("https://contoso.sharepoint.com/sites/somesite"), newGroupOwners);
```

By default `SetSiteCollectionAdmins` adds `newAdmins` to the list of existing site collection admins. By setting the optional `CollectionUpdateOptions` parameter to `SetExact` the `newAdmins` list will be set exactly and all other admins
will be removed.


```csharp
// Set the site collection admins for a regular site
List<string> newAdmins = new List<string>();
newAdmins.Add("i:0#.f|membership|[email protected]");
newAdmins.Add("c:0-.f|rolemanager|spo-grid-all-users/6492ece7-7f5d-4499-8130-50e761e25bd9");

context.GetSiteCollectionManager().SetSiteCollectionAdmins(
new Uri("https://contoso.sharepoint.com/sites/somesite"),
newAdmins,
null,
CollectionUpdateOptions.SetExact
);
```

A certain `ISiteCollectionAdmin` can be set as primary site collection administrator using `SetAsPrimarySiteCollectionAdministrator`:

```csharp
// Get admins
List<ISiteCollectionAdmin> admins = context
.GetSiteCollectionManager()
.GetSiteCollectionAdmins(new Uri("https://contoso.sharepoint.com/sites/somesite"));

// Set the first as primary site collection administrator
admins.First()
.SetAsPrimarySiteCollectionAdministratorAsync(new Uri("https://contoso.sharepoint.com/sites/somesite"));

```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"dcabb4a0-0044-6000-a269-c34f205983f2","SPClientServiceRequestDuration":"18","X-SharePointHealthScore":"2","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022RegionalSettings\u0022:{\u0022TimeZone\u0022:{\u0022Description\u0022:\u0022(UTC\u002B01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna\u0022,\u0022Id\u0022:4,\u0022Information\u0022:{\u0022Bias\u0022:-60,\u0022DaylightBias\u0022:-60,\u0022StandardBias\u0022:0}},\u0022AdjustHijriDays\u0022:0,\u0022AlternateCalendarType\u0022:0,\u0022AM\u0022:\u0022AM\u0022,\u0022CalendarType\u0022:1,\u0022Collation\u0022:25,\u0022CollationLCID\u0022:2070,\u0022DateFormat\u0022:0,\u0022DateSeparator\u0022:\u0022/\u0022,\u0022DecimalSeparator\u0022:\u0022.\u0022,\u0022DigitGrouping\u0022:\u00223;0\u0022,\u0022FirstDayOfWeek\u0022:0,\u0022FirstWeekOfYear\u0022:0,\u0022IsEastAsia\u0022:false,\u0022IsRightToLeft\u0022:false,\u0022IsUIRightToLeft\u0022:false,\u0022ListSeparator\u0022:\u0022,\u0022,\u0022LocaleId\u0022:1033,\u0022NegativeSign\u0022:\u0022-\u0022,\u0022NegNumberMode\u0022:1,\u0022PM\u0022:\u0022PM\u0022,\u0022PositiveSign\u0022:\u0022\u0022,\u0022ShowWeeks\u0022:false,\u0022ThousandSeparator\u0022:\u0022,\u0022,\u0022Time24\u0022:false,\u0022TimeMarkerPosition\u0022:0,\u0022TimeSeparator\u0022:\u0022:\u0022,\u0022WorkDayEndHour\u0022:1020,\u0022WorkDays\u0022:62,\u0022WorkDayStartHour\u0022:480},\u0022Id\u0022:\u00225c1693ab-3bab-4780-812e-23bf82ba06cc\u0022,\u0022Url\u0022:\u0022https://loitzl2.sharepoint.com/sites/pnpcoresdktestgroup\u0022}"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"dcabb4a0-804b-6000-a269-c0a421f326a1","SPClientServiceRequestDuration":"7","X-SharePointHealthScore":"1","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022GroupId\u0022:\u0022e351a3ff-1595-4979-b588-88038f993cc6\u0022,\u0022Id\u0022:\u002269fad637-9681-4e09-b667-75b94e7898fb\u0022}"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"dcabb4a0-c04e-6000-a269-ce81d83fd5fd","SPClientServiceRequestDuration":"2391","X-SharePointHealthScore":"3","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022SiteId\u0022:\u002291c5423a-300b-4c89-954e-f31a7d09bbc3\u0022,\u0022SiteStatus\u0022:2,\u0022SiteUrl\u0022:\u0022https://loitzl2.sharepoint.com/sites/pnpcoresdktestcommsited1fd44e8f6924182ba1f10966256d661\u0022}"}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"e2abb4a0-406c-6000-a269-c0a27e74acda","SPClientServiceRequestDuration":"9","X-SharePointHealthScore":"2","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022RegionalSettings\u0022:{\u0022TimeZone\u0022:{\u0022Description\u0022:\u0022(UTC\u002B01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna\u0022,\u0022Id\u0022:4,\u0022Information\u0022:{\u0022Bias\u0022:-60,\u0022DaylightBias\u0022:-60,\u0022StandardBias\u0022:0}},\u0022AdjustHijriDays\u0022:0,\u0022AlternateCalendarType\u0022:0,\u0022AM\u0022:\u0022AM\u0022,\u0022CalendarType\u0022:1,\u0022Collation\u0022:25,\u0022CollationLCID\u0022:2070,\u0022DateFormat\u0022:0,\u0022DateSeparator\u0022:\u0022/\u0022,\u0022DecimalSeparator\u0022:\u0022.\u0022,\u0022DigitGrouping\u0022:\u00223;0\u0022,\u0022FirstDayOfWeek\u0022:0,\u0022FirstWeekOfYear\u0022:0,\u0022IsEastAsia\u0022:false,\u0022IsRightToLeft\u0022:false,\u0022IsUIRightToLeft\u0022:false,\u0022ListSeparator\u0022:\u0022,\u0022,\u0022LocaleId\u0022:1033,\u0022NegativeSign\u0022:\u0022-\u0022,\u0022NegNumberMode\u0022:1,\u0022PM\u0022:\u0022PM\u0022,\u0022PositiveSign\u0022:\u0022\u0022,\u0022ShowWeeks\u0022:false,\u0022ThousandSeparator\u0022:\u0022,\u0022,\u0022Time24\u0022:false,\u0022TimeMarkerPosition\u0022:0,\u0022TimeSeparator\u0022:\u0022:\u0022,\u0022WorkDayEndHour\u0022:1020,\u0022WorkDays\u0022:62,\u0022WorkDayStartHour\u0022:480},\u0022Id\u0022:\u00225c1693ab-3bab-4780-812e-23bf82ba06cc\u0022,\u0022Url\u0022:\u0022https://loitzl2.sharepoint.com/sites/pnpcoresdktestgroup\u0022}"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"e2abb4a0-d06e-6000-a269-c50f31385603","SPClientServiceRequestDuration":"8","X-SharePointHealthScore":"1","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022GroupId\u0022:\u0022e351a3ff-1595-4979-b588-88038f993cc6\u0022,\u0022Id\u0022:\u002269fad637-9681-4e09-b667-75b94e7898fb\u0022}"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"dcabb4a0-10e8-6000-a269-c07f5f65e993","SPClientServiceRequestDuration":"21","X-SharePointHealthScore":"0","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022RegionalSettings\u0022:{\u0022TimeZone\u0022:{\u0022Description\u0022:\u0022(UTC\u002B01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna\u0022,\u0022Id\u0022:4,\u0022Information\u0022:{\u0022Bias\u0022:-60,\u0022DaylightBias\u0022:-60,\u0022StandardBias\u0022:0}},\u0022AdjustHijriDays\u0022:0,\u0022AlternateCalendarType\u0022:0,\u0022AM\u0022:\u0022AM\u0022,\u0022CalendarType\u0022:1,\u0022Collation\u0022:25,\u0022CollationLCID\u0022:2070,\u0022DateFormat\u0022:0,\u0022DateSeparator\u0022:\u0022/\u0022,\u0022DecimalSeparator\u0022:\u0022.\u0022,\u0022DigitGrouping\u0022:\u00223;0\u0022,\u0022FirstDayOfWeek\u0022:0,\u0022FirstWeekOfYear\u0022:0,\u0022IsEastAsia\u0022:false,\u0022IsRightToLeft\u0022:false,\u0022IsUIRightToLeft\u0022:false,\u0022ListSeparator\u0022:\u0022,\u0022,\u0022LocaleId\u0022:1033,\u0022NegativeSign\u0022:\u0022-\u0022,\u0022NegNumberMode\u0022:1,\u0022PM\u0022:\u0022PM\u0022,\u0022PositiveSign\u0022:\u0022\u0022,\u0022ShowWeeks\u0022:false,\u0022ThousandSeparator\u0022:\u0022,\u0022,\u0022Time24\u0022:false,\u0022TimeMarkerPosition\u0022:0,\u0022TimeSeparator\u0022:\u0022:\u0022,\u0022WorkDayEndHour\u0022:1020,\u0022WorkDays\u0022:62,\u0022WorkDayStartHour\u0022:480},\u0022Id\u0022:\u00227b0965bc-62d5-419f-9107-79ab4df9a81c\u0022,\u0022Url\u0022:\u0022https://loitzl2.sharepoint.com/sites/pnpcoresdktestcommsited1fd44e8f6924182ba1f10966256d661\u0022}"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"dcabb4a0-00eb-6000-a269-cf79e4f034bd","SPClientServiceRequestDuration":"8","X-SharePointHealthScore":"3","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022GroupId\u0022:\u002200000000-0000-0000-0000-000000000000\u0022,\u0022Id\u0022:\u002291c5423a-300b-4c89-954e-f31a7d09bbc3\u0022}"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"e2abb4a0-a070-6000-a269-c5207554f1db","SPClientServiceRequestDuration":"9","X-SharePointHealthScore":"0","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022RegionalSettings\u0022:{\u0022TimeZone\u0022:{\u0022Description\u0022:\u0022(UTC-08:00) Pacific Time (US and Canada)\u0022,\u0022Id\u0022:13,\u0022Information\u0022:{\u0022Bias\u0022:480,\u0022DaylightBias\u0022:-60,\u0022StandardBias\u0022:0}},\u0022AdjustHijriDays\u0022:0,\u0022AlternateCalendarType\u0022:0,\u0022AM\u0022:\u0022AM\u0022,\u0022CalendarType\u0022:1,\u0022Collation\u0022:25,\u0022CollationLCID\u0022:2070,\u0022DateFormat\u0022:0,\u0022DateSeparator\u0022:\u0022/\u0022,\u0022DecimalSeparator\u0022:\u0022.\u0022,\u0022DigitGrouping\u0022:\u00223;0\u0022,\u0022FirstDayOfWeek\u0022:0,\u0022FirstWeekOfYear\u0022:0,\u0022IsEastAsia\u0022:false,\u0022IsRightToLeft\u0022:false,\u0022IsUIRightToLeft\u0022:false,\u0022ListSeparator\u0022:\u0022,\u0022,\u0022LocaleId\u0022:1033,\u0022NegativeSign\u0022:\u0022-\u0022,\u0022NegNumberMode\u0022:1,\u0022PM\u0022:\u0022PM\u0022,\u0022PositiveSign\u0022:\u0022\u0022,\u0022ShowWeeks\u0022:false,\u0022ThousandSeparator\u0022:\u0022,\u0022,\u0022Time24\u0022:false,\u0022TimeMarkerPosition\u0022:0,\u0022TimeSeparator\u0022:\u0022:\u0022,\u0022WorkDayEndHour\u0022:1020,\u0022WorkDays\u0022:62,\u0022WorkDayStartHour\u0022:480},\u0022Id\u0022:\u002208a02a87-87f3-4c3e-ba7e-ff19e4155bd4\u0022,\u0022Url\u0022:\u0022https://loitzl2-admin.sharepoint.com\u0022}"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"e2abb4a0-7072-6000-8be3-d701f2c9db06","SPClientServiceRequestDuration":"60","X-SharePointHealthScore":"1","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022GroupId\u0022:\u002200000000-0000-0000-0000-000000000000\u0022,\u0022Id\u0022:\u00221d0f657f-36f7-4b9f-af00-94dcc1224811\u0022}"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"e2abb4a0-30a6-6000-8be3-da6745db35d7","SPClientServiceRequestDuration":"1042","X-SharePointHealthScore":"2","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"[\r{\r\u0022SchemaVersion\u0022:\u002215.0.0.0\u0022,\u0022LibraryVersion\u0022:\u002216.0.23703.12002\u0022,\u0022ErrorInfo\u0022:null,\u0022TraceCorrelationId\u0022:\u0022e2abb4a0-30a6-6000-8be3-da6745db35d7\u0022\r},3,{\r\u0022_ObjectType_\u0022:\u0022Microsoft.Online.SharePoint.TenantAdministration.SpoOperation\u0022,\u0022_ObjectIdentity_\u0022:\u0022e2abb4a0-30a6-6000-8be3-da6745db35d7|908bed80-a04a-4433-b4a0-883d9847d110:60df2466-a102-404a-8d9d-95c950626730\\nSpoOperation\\nRemoveDeletedSite\\n638201730289866160\\nhttps%3a%2f%2floitzl2.sharepoint.com%2fsites%2fpnpcoresdktestcommsited1fd44e8f6924182ba1f10966256d661\\n91c5423a-300b-4c89-954e-f31a7d09bbc3\u0022,\u0022PollingInterval\u0022:15000,\u0022IsComplete\u0022:true\r}\r]"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"dcabb4a0-50fd-6000-8d63-b05897af1a14","SPClientServiceRequestDuration":"12","X-SharePointHealthScore":"3","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022RegionalSettings\u0022:{\u0022TimeZone\u0022:{\u0022Description\u0022:\u0022(UTC-08:00) Pacific Time (US and Canada)\u0022,\u0022Id\u0022:13,\u0022Information\u0022:{\u0022Bias\u0022:480,\u0022DaylightBias\u0022:-60,\u0022StandardBias\u0022:0}},\u0022AdjustHijriDays\u0022:0,\u0022AlternateCalendarType\u0022:0,\u0022AM\u0022:\u0022AM\u0022,\u0022CalendarType\u0022:1,\u0022Collation\u0022:25,\u0022CollationLCID\u0022:2070,\u0022DateFormat\u0022:0,\u0022DateSeparator\u0022:\u0022/\u0022,\u0022DecimalSeparator\u0022:\u0022.\u0022,\u0022DigitGrouping\u0022:\u00223;0\u0022,\u0022FirstDayOfWeek\u0022:0,\u0022FirstWeekOfYear\u0022:0,\u0022IsEastAsia\u0022:false,\u0022IsRightToLeft\u0022:false,\u0022IsUIRightToLeft\u0022:false,\u0022ListSeparator\u0022:\u0022,\u0022,\u0022LocaleId\u0022:1033,\u0022NegativeSign\u0022:\u0022-\u0022,\u0022NegNumberMode\u0022:1,\u0022PM\u0022:\u0022PM\u0022,\u0022PositiveSign\u0022:\u0022\u0022,\u0022ShowWeeks\u0022:false,\u0022ThousandSeparator\u0022:\u0022,\u0022,\u0022Time24\u0022:false,\u0022TimeMarkerPosition\u0022:0,\u0022TimeSeparator\u0022:\u0022:\u0022,\u0022WorkDayEndHour\u0022:1020,\u0022WorkDays\u0022:62,\u0022WorkDayStartHour\u0022:480},\u0022Id\u0022:\u002208a02a87-87f3-4c3e-ba7e-ff19e4155bd4\u0022,\u0022Url\u0022:\u0022https://loitzl2-admin.sharepoint.com\u0022}"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"dcabb4a0-a0ff-6000-8d63-be7f3dc36b14","SPClientServiceRequestDuration":"8","X-SharePointHealthScore":"3","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022GroupId\u0022:\u002200000000-0000-0000-0000-000000000000\u0022,\u0022Id\u0022:\u00221d0f657f-36f7-4b9f-af00-94dcc1224811\u0022}"}
Loading