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();
    }
}
