question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Task.Definition.Principal.Account is null if in the UserId property of the task XML, is set in plain text, instead of SID

See original GitHub issue

I need to get a task’ associated principal, which is set in ‘When running the task use the following user account’. However, on some machines, the UserId in the task’s XML is represented by Sid:

<Principal id="Author">
      <RunLevel>HighestAvailable</RunLevel>
      <UserId>S-1-5-21-2025382838-34760544-43243242434-1106</UserId>
      <LogonType>Password</LogonType>
</Principal>

In which case this works fine and I can retrieve the account, but on other machines the UserId is represented in plain text:

<Principal id="Author">
      <RunLevel>HighestAvailable</RunLevel>
      <UserId>Domain\User</UserId>
      <LogonType>Password</LogonType>
</Principal>

In which case Task.Definition.Principal.Account returns null

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dahallcommented, Oct 15, 2019

@karthimahendran Use the Account property. It will always return the username.

@msmilkoff I’m glad this fixed your problem. I’ll publish 2.8.16 today with the fix.

1reaction
dahallcommented, Sep 30, 2019

Thanks for your workaround. It helped me have an idea as to how to prevent even though this is really Microsoft’s library’s problem. I’ll look into it and let you know what I find.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TaskScheduler RegisterTaskDefinition fails with (38:4)UserID
Question. How do you register a scheduled task with the Task Scheduler 2.0 COM object API? Look at the answer in the back...
Read more >
Principal.UserId property - Win32 apps
When reading or writing XML for a task, the user identifier for the principal is specified using the UserId element of the Task...
Read more >
Chapter 15 SQL Structured Query Language
In this chapter, we will focus on using SQL to create the database and table structures, mainly using SQL as a data definition...
Read more >
Configure Windows service accounts and permissions
This article helps advanced users understand the details of the service accounts. Most services and their properties can be configured by using ...
Read more >
SQL MP Run As Accounts – NO LONGER REQUIRED
This creates a login in SQL, and allows the SCOM agent to be able to monitor SQL server, without having to maintain another...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found