IPrincipal::LogonType property

Gets or sets the security logon method that is required to run the tasks that are associated with the principal.

This property is read/write.

Syntax


HRESULT put_LogonType(
  [in]  TASK_LOGON TYPE logon
);

HRESULT get_LogonType(
  [out] TASK_LOGON TYPE *pLogon
);

Property value

Sets to one of the following TASK_LOGON TYPE enumeration constants.

ValueMeaning
TASK_LOGON_NONE
0

The logon method is not specified. Used for non-NT credentials.

TASK_LOGON_PASSWORD
1

Use a password for logging on the user. The password must be supplied at registration time.

TASK_LOGON_S4U
2

Use an existing interactive token to run a task. The user must log on using a service for user (S4U) logon. When an S4U logon is used, no password is stored by the system and there is no access to either the network or encrypted files.

TASK_LOGON_INTERACTIVE_TOKEN
3

User must already be logged on. The task will be run only in an existing interactive session.

TASK_LOGON_GROUP
4

Group activation. The userId field specifies the group.

TASK_LOGON_SERVICE_ACCOUNT
5

Indicates that a Local System, Local Service, or Network Service account is being used as a security context to run the task.

TASK_LOGON_INTERACTIVE_TOKEN_OR_PASSWORD
6

First use the interactive token. If the user is not logged on (no interactive token is available), then the password is used. The password must be specified when a task is registered. This flag is not recommended for new tasks because it is less reliable than TASK_LOGON_PASSWORD.

 

Error codes

NameMeaning
S_OK

The property value was successfully set or retrieved.

Remarks

This property is valid only when a user identifier is specified by the UserId property.

When reading or writing XML for a task, the logon type is specified in the <LogonType> element of the Task Scheduler schema.

For a task, that contains a message box action, the message box will be displayed if the task is activated and the task has an interactive logon type. To set the task logon type to be interactive, specify TASK_LOGON_INTERACTIVE_TOKEN or TASK_LOGON_GROUP in the LogonType property of the task principal, or in the logonType parameter of ITaskFolder::RegisterTask or ITaskFolder::RegisterTaskDefinition.

When battery saver is on, Windows Task Scheduler tasks are triggered only if the task is:

  • Not set to Start the task only if the computer is idle... (task doesn't use IdleSettings)
  • Not set to run during automatic maintenance (task doesn't use MaintenanceSettings)
  • Is set to Run only when user is logged on (task LogonType is TASK_LOGON_INTERACTIVE_TOKEN or TASK_LOGON_GROUP)

All other triggers are delayed until battery saver is off. For more information about accessing battery saver status in your application, see SYSTEM_POWER_STATUS. For general information about battery saver, see battery saver (in the hardware component guidelines).

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Taskschd.h

Library

Taskschd.lib

DLL

Taskschd.dll

See also

Task Scheduler
IPrincipal

 

 

Show: