A required privilege is not held by the client Exception from HRESULT: 0x80070522

Sep 17, 2012 at 12:58 PM


I just found this library and the configuration is great. Unfortunately I get an exception in my Taskservice: Exception from HRESULT: 0x80070522. Any idea?

Here is the code:

using (TaskService ts = new TaskService())
                var taskDefinition = GetBackupTaskDefinition(ts, taskName);
                if (taskDefinition == null)
                    taskDefinition = ts.NewTask();
                taskDefinition.RegistrationInfo.Description = "backuplandreg";
                taskDefinition.Principal.LogonType = TaskLogonType.InteractiveToken;

                if(HandlerSettings.BackupCycle == 0)//Every day
                   var trigger = new DailyTrigger { DaysInterval = 1 };
                    trigger.StartBoundary = DateTime.Today + TimeSpan.FromHours(Convert.ToInt16(HandlerSettings.BackupTime));
                else if(HandlerSettings.BackupCycle == 1)//Every week
                   var trigger = new WeeklyTrigger();
                    trigger.DaysOfWeek = GetDay();
                    trigger.StartBoundary = DateTime.Today + TimeSpan.FromHours(14.3);
                else if(HandlerSettings.BackupCycle == 2)//Every Month
                    var trigger = new MonthlyTrigger();
                    trigger.DaysOfMonth = new int[GetFirstDayOfMonth(GetDay()).Day];
                    trigger.StartBoundary = DateTime.Today +

                string actionString = "C:\\test2.bat {0} {1} {2} {3} {4}";
                var action =
                    new ExecAction(
                        String.Format(actionString, DataSettings.Database,
                                      HandlerSettings.BackupDirectory.Remove(HandlerSettings.BackupDirectory.LastIndexOf("\\"),1), DataSettings.Host, DataSettings.Port,
                                      DataSettings.UserName), null);

               TaskFolder taskFolder = ts.RootFolder.SubFolders.FirstOrDefault(f => f.Name == "MyTaskFolder")?? ts.RootFolder.CreateFolder("MyTaskFolder");

                taskFolder.RegisterTaskDefinition(taskName, taskDefinition);

Actually the exception is already thrown in the TaskService. I am running my project on a Win7 64bit Version.

Thanks in advance

Sep 18, 2012 at 3:07 PM

At which line in the code is the exception thrown?

Sep 21, 2012 at 4:14 PM

The error code suggests that "A required privilege is not held by the client". I would therefore check to make sure that the account you have connected the TaskService with have sufficient privileges to create tasks. There are some other articles in this discussion area that discuss privileges and some links to Microsoft documentation on the same.