Files
Sharepoint-Toolbox/SharepointToolbox/Services/OwnershipElevationService.cs
Dev 36fb312b5a feat(18-01): models, SettingsService, OwnershipElevationService + tests
- AppSettings.AutoTakeOwnership bool property defaulting to false
- PermissionEntry.WasAutoElevated optional param (default false, last position)
- SettingsService.SetAutoTakeOwnershipAsync persists toggle
- IOwnershipElevationService interface + OwnershipElevationService wrapping Tenant.SetSiteAdmin
- SettingsViewModel.AutoTakeOwnership property loads and persists via SetAutoTakeOwnershipAsync
- DI registration in App.xaml.cs (Phase 18 section)
- 8 new tests: models, persistence, service, viewmodel
2026-04-09 14:23:08 +02:00

15 lines
503 B
C#

using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
namespace SharepointToolbox.Services;
public class OwnershipElevationService : IOwnershipElevationService
{
public async Task ElevateAsync(ClientContext tenantAdminCtx, string siteUrl, string loginName, CancellationToken ct)
{
var tenant = new Tenant(tenantAdminCtx);
tenant.SetSiteAdmin(siteUrl, loginName, isSiteAdmin: true);
await tenantAdminCtx.ExecuteQueryAsync();
}
}