Question

Is there any way to get all local contentdeployment jobs from within web application code?

I'm trying to list all jobs on an aspx page in the backend of a site collection, but everytime I execute this:

ContentDeploymentJob.GetAllJobs()

an AccessDenied Exception raises, saying that the executing user is not a farm admin. If I try it with ElevatedPriviliges or Impersonation as farm admin it doesnt work too.

Was it helpful?

Solution

After a few months of not thinking about this issue I found an answer:

Execute the following PowerShell Script and it should work (tested on a standalone farm):

PS C:\Users\xxx> $contentService  = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
PS C:\Users\xxx> $contentService.RemoteAdministratorAccessDenied = $false
PS C:\Users\xxx> $contentService.Update()

Here my testing code (executed in a webpart):

try
{
    ContentDeploymentJobCollection jobs = ContentDeploymentJob.GetAllJobs();
    foreach (ContentDeploymentJob job in jobs)
    {
        BulletedList1.Items.Add(job.Name);
    }
 }
 catch (Exception ex)
 {
     BulletedList1.Items.Add(ex.Message);
 }
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top