Skip to content

Commit

Permalink
Added LogonType documentation to 2024.3 and 2024.5
Browse files Browse the repository at this point in the history
  • Loading branch information
cortex-jk authored Jun 27, 2024
1 parent 713436f commit 4f634de
Show file tree
Hide file tree
Showing 9 changed files with 431 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,16 @@ As a result, any issues with using the [Result][Result Property] (i.e. trying to

If it is desirable to have any issues reported as messages when trying to debug the flow, the user can [cast][Object Casting] the [Result][Result Property] to its correct type.

### RunAs

RunAs can be used to connect to a database as a Windows user, rather than a SQL user.

To connect as a Windows user:
- An appropriate connection string (e.g. [Oracle][OracleConnectionStringIntegratedSecurity], [SQL Server][SqlConnectionStringTrustedConnection]) must be specified in the [Connection Details][Connection Details Property].
- [UserCredentials][] for the Windows user must be specified in the [Run As property][RunAsProperty].

If connecting to a local database, the [UserCredentials][] must specify the [LogonType][] to be `LogonType.Network`; if connecting to a remote database, the [LogonType][] must be `LogonType.NewCredentials`.

### Known Limitations

When using a [Parameterised Command][Parameterised Commands] to execute a stored procedure, it is not possible to write back to output parameters.
Expand Down Expand Up @@ -783,7 +793,14 @@ When using a [Parameterised Command][Parameterised Commands] to execute a stored
[Variables]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Variables.MainDoc" >}}
[Object Casting]: {{< url path="Cortex.Reference.Concepts.WorkingWith.Objects.ObjectCasting.MainDoc" >}}

[UserCredentials]: {{< url path="Cortex.Reference.DataTypes.Credentials.UserCredentials.MainDoc" >}}
[LogonType]: {{< url path="Cortex.Reference.DataTypes.Credentials.UserCredentials.LogonType" >}}
[RunAsProperty]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.CommonProperties.RunAsProperty" >}}

[Advanced]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.AdvancedProperties.MainDoc" >}}

[OracleBlockStatement]: {{< url path="Oracle.PL-SQL.BlockStatement" >}}
[SQL Injection]: {{< url path="W3.SqlInjection" >}}

[SqlConnectionStringTrustedConnection]: {{< url path="ConnectionStrings.SqlConnectionTrustedConnection" >}}
[OracleConnectionStringIntegratedSecurity]: {{< url path="ConnectionStrings.OracleConnectionIntegratedSecurity" >}}
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ Once the [block][] has finished executing, the next block to execute will run as

The default value of `null` also results in the [block][] executing as the user the [Execution Service][] is running as.

If [UserCredentials][] has an invalid domain, username or password, a [RunAsException][] will be thrown when the [block][] is executed.
If [UserCredentials][] has an invalid domain, username, password or [LogonType][UserCredentialsLogonType], a [RunAsException][] will be thrown when the [block][] is executed.

If [UserCredentials][] has a `null` username or password, a [PropertyNullException][] will be thrown when the [block][] is executed.

By default, the type of logon method used to authenticate the Run As user is `LogonType.Network`; this works for most scenarios. For scenarios that require a different type of logon method (e.g. connecting to a remote database), the correct [LogonType][] (e.g. `LogonType.NewCredentials`) can be specified as part of the [UserCredentials][].

{{< figure src="/images/set-variable/set-variable-run-as.svg" >}}

## Block Timeout Property
Expand Down Expand Up @@ -126,6 +128,7 @@ None
[Executions]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Executions.WhatIsAnExecution.MainDoc" >}}
[WhatIsBlock]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Blocks.WhatIsABlock.MainDoc" >}}
[Execution Service]: {{< url path="Cortex.Guides.CortexInnovation.ExecutionApplication.Services.ExecutionService.MainDoc" >}}
[LogonType]: {{< url path="Cortex.Reference.DataTypes.Credentials.LogonType.MainDoc" >}}

[Exceptions]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Exceptions.MainDoc" >}}

Expand All @@ -138,6 +141,8 @@ None
[TimePeriod]: {{< url path="Cortex.Reference.DataTypes.DateAndTime.TimePeriod.MainDoc" >}}
[UserCredentials]: {{< url path="Cortex.Reference.DataTypes.Credentials.UserCredentials.MainDoc" >}}

[UserCredentialsLogonType]: {{< url path="Cortex.Reference.DataTypes.Credentials.UserCredentials.LogonType" >}}

[BlockTimeoutException]: {{< url path="Cortex.Reference.Exceptions.Flows.Blocks.BlockTimeoutException.MainDoc" >}}
[InvalidBlockTimeoutException]: {{< url path="Cortex.Reference.Exceptions.Flows.Blocks.InvalidBlockTimeoutException.MainDoc" >}}

Expand Down
173 changes: 173 additions & 0 deletions content/en/docs/2024.3/Reference/data-types/credentials/logontype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
---
title: "LogonType"
linkTitle: "LogonType"
description: "Used to represent the Logon type used for the UserCredentials."
---

# {{% param title %}}

<p class="namespace">(Cortex.DataTypes.Credentials.LogonType)</p>

## Summary

The `LogonType` data type is used to represent the type of logon method to use to authenticate a user.

`LogonType` is an [enum][Working with Enums] data type, which means it has a defined set of values, where each value has an associated [String][] name and [Int32][] value.

| | |
|---------------------|------------------------------------------------------------------------------------------------------------------------------------|
| **Category:** | Credentials |
| **Name:** | `LogonType` |
| **Full Name:** | `Cortex.DataTypes.Credentials.LogonType` |
| **Alias:** | N/A |
| **Description:** | Used to represent the type of logon method to use to authenticate a user. |
| **Default Value:** | `LogonType.Network` |
| **Can be used as:** | `LogonType`, `Object`, `dynamic` |
| **Can be cast to:** | `Int16` (e.g. `(Int16)LogonType.Network` or `(System.Int16)LogonType.Network` or `(short)LogonType.Network`) |
| | `Int32` (e.g. `(Int32)LogonType.Network` or `(System.Int32)LogonType.Network` or `(int)LogonType.Network`) |
| | `Int64` (e.g. `(Int64)LogonType.Network` or `(System.Int64)LogonType.Network` or `(long)LogonType.Network`) |
| | `Single` (e.g. `(Single)LogonType.Network` or `(System.Single)LogonType.Network` or `(float)LogonType.Network`) |
| | `Double` (e.g. `(Double)LogonType.Network` or `(System.Double)LogonType.Network` or `(double)LogonType.Network`) |

## Values

### Network

| | |
|------------|----------------------------|
| **Name:** | Network |
| **Value:** | [Int32][] with value `3` |
| **Notes:** | Represents a network logon. This should be used in most cases, including when connecting to a local database as a Windows user. If connecting to a remote database as a Windows user, [NewCredentials][] should be used. |

### NetworkCleartext

| | |
|------------|----------------------------|
| **Name:** | NetworkCleartext |
| **Value:** | [Int32][] with value `8` |
| **Notes:** | Represents a network logon. This differs from [Network][] as the user's password will be passed as cleartext. This should be used when authenticating with IIS using Basic Auth, and Windows PowerShell with CredSSP. |

### NewCredentials

| | |
|------------|----------------------------|
| **Name:** | NewCredentials |
| **Value:** | [Int32][] with value `9` |
| **Notes:** | Represents a clone of the user's current logon. For local operations, it uses the same local identity. For network operations, it uses the identity of the credentials supplied. This should be used when authenticating against a remote database as a Windows User. If connecting to a local database as a Windows user, [Network][] should be used. |

## Remarks

### Create LogonType

The following table shows some of the ways that `LogonType` can be created using the expression editor.

| Method | Example | Result | Editor&nbsp;Support | Notes |
|-|-|-|-|-|
| Use a `LogonType` expression | `LogonType.Network` | `LogonType.Network`| Expression | |
| | `LogonType.NetworkCleartext` | `LogonType.NetworkCleartext` | Expression | |
| | `LogonType.NewCredentials` | `LogonType.NewCredentials` | Expression | |
| Use [Explicit Casting][] | `(LogonType)3` | `LogonType.Network`| Expression | |
| | `(LogonType)8` | `LogonType.NetworkCleartext` | Expression | |
| | `(LogonType)9` | `LogonType.NewCredentials` | Expression | |
| Use `Enum.Parse` | `(LogonType)Enum.Parse(typeof(LogonType), "Network")` | `LogonType.Network`| Expression | Parses `"Network"` and converts it to `LogonType.Network`. See [Enum.Parse][] |
| | `(LogonType)Enum.Parse(typeof(LogonType), "NetworkCleartext")` | `LogonType.NetworkCleartext`| Expression | Parses `"NetworkCleartext"` and converts it to `LogonType.NetworkCleartext`. See [Enum.Parse][] |
| | `(LogonType)Enum.Parse(typeof(LogonType), "NewCredentials")` | `LogonType.NewCredentials`| Expression | Parses `"NewCredentials"` and converts it to `LogonType.NewCredentials`. See [Enum.Parse][] |
| Use `Enum.ToObject` | `(LogonType)Enum.ToObject(typeof(LogonType), 3)` | `LogonType.Network`| Expression | Converts `3` to `LogonType.Network` value. See [Enum.ToObject][] |
| | `(LogonType)Enum.ToObject(typeof(LogonType), 8)` | `LogonType.NetworkCleartext` | Expression | Converts `8` to `LogonType.NetworkCleartext` value. See [Enum.ToObject][] |
| | `(LogonType)Enum.ToObject(typeof(LogonType), 9)` | `LogonType.NewCredentials` | Expression | Converts `9` to `LogonType.NewCredentials` value. See [Enum.ToObject][] |

Please see [Instantiating an enumeration type][] for further information.

### Convert LogonType to Text

The following table shows some of the ways that a `LogonType` can be converted to text.

| Method | Example | Result | Editor&nbsp;Support | Notes |
|-|-|-|-|-|
| Use `ToString` | `LogonType.Network.ToString()` | `"Network"` | Expression | Converts `LogonType.Network` to `"Network"`. See [Enum.ToString][] |
| | `LogonType.NetworkCleartext.ToString()` | `"NetworkCleartext"` | Expression | Converts `LogonType.NetworkCleartext` to `"NetworkCleartext"`. See [Enum.ToString][] |
| | `LogonType.NewCredentials.ToString()` | `"NewCredentials"` | Expression | Converts `LogonType.NewCredentials` to `"NewCredentials"`. See [Enum.ToString][] |
| Use `Convert.ToString` | `Convert.ToString(LogonType.Network)` | `"Network"` | Expression | Converts `LogonType.Network` to `"Network"`. See [Convert.ToString][] |
| | `Convert.ToString(LogonType.NetworkCleartext)` | `"NetworkCleartext"` | Expression | Converts `LogonType.NetworkCleartext` to `"NetworkCleartext"`. See [Convert.ToString][] |
| | `Convert.ToString(LogonType.NewCredentials)` | `"NewCredentials"` | Expression | Converts `LogonType.NewCredentials` to `"NewCredentials"`. See [Convert.ToString][] |
| Use `Convert Object To Text` block | where `Object` property has a value of `LogonType.Network` | `"Network"` | N/A | Converts `LogonType.Network` to `"Network"`. See [Convert Object To Text][] |
| | where `Object` property has a value of `LogonType.NetworkCleartext` | `"NetworkCleartext"` | N/A | Converts `LogonType.NetworkCleartext` to `"NetworkCleartext"`. See [Convert Object To Text][] |
| | where `Object` property has a value of `LogonType.NewCredentials` | `"NewCredentials"` | N/A | Converts `LogonType.NewCredentials` to `"NewCredentials"`. See [Convert Object To Text][] |
| Use `Convert Object To Json` block | where `Object` property has a value of `LogonType.Network` | `"3"` | N/A | Converts `LogonType.Network` to `"3"`. See [Convert Object To Json][] |
| | where `Object` property has a value of `LogonType.NetworkCleartext` | `"8"` | N/A | Converts `LogonType.NetworkCleartext` to `"8"`. See [Convert Object To Json][] |
| | where `Object` property has a value of `LogonType.NewCredentials` | `"9"` | N/A | Converts `LogonType.NewCredentials` to `"9"`. See [Convert Object To Json][] |

Please see [Formatting enumeration values][] for further information.

### Convert LogonType to a Number

The following table shows some of the ways that a `LogonType` can be converted to a number.

| Method | Example | Result | Editor&nbsp;Support | Notes |
|-|-|-|-|-|
| Use [Explicit Casting][] | `(Int32)LogonType.Network` | `3` | Expression | [Casts][Explicit Casting] `LogonType.Network` to `3` |
| | `(Int32)LogonType.NetworkCleartext` | `8` | Expression | [Casts][Explicit Casting] `LogonType.NetworkCleartext` to `8` |
| | `(Int32)LogonType.NewCredentials` | `9` | Expression | [Casts][Explicit Casting] `LogonType.NewCredentials` to `9` |
| Use `Convert.ToInt32` | `Convert.ToInt32(LogonType.Network)` | `3` | Expression | Converts `LogonType.Network` to `3`. See [Convert.ToInt32][] |
| | `Convert.ToInt32(LogonType.NetworkCleartext)` | `8` | Expression | Converts `LogonType.NetworkCleartext` to `8`. See [Convert.ToInt32][] |
| | `Convert.ToInt32(LogonType.NewCredentials)` | `9` | Expression | Converts `LogonType.NewCredentials` to `9`. See [Convert.ToInt32][] |

### Property Editor Support

- The Expression Editor is available for [Input][] properties where the data type is `LogonType`.
- The Literal Editor is available for [Input][] properties where the data type is `LogonType`.
- The Variable Editor is available for [Input][], [InputOutput][] and [Output][] properties where the data type is `LogonType`.

### Known Limitations

- When [LogonType][] is set to `LogonType.NewCredentials` and trying to connect to a localhost database, it will not recognise the UserCredentials. To fix this use `LogonType.Network` as the [LogonType][].
- When [LogonType][] is set to `LogonType.Network` and trying to connect to a remote database, it will not recognise the UserCredentials. To fix this use `LogonType.NewCredentials` as the [LogonType][].

## See Also

### Related Data Types

- [Int32][]
- [String][]
- [UserCredentials][]

### Related Concepts

- [Explicit Casting][]
- [Working with Enums][]

### External Documentation

- [LogonTypes][]
- [System.Enum][]

[Network]: {{< ref "#network" >}}
[NewCredentials]: {{< ref "#newcredentials" >}}

[Input]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.WhatIsABlockProperty.Input" >}}
[Output]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.WhatIsABlockProperty.Output" >}}
[InputOutput]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.WhatIsABlockProperty.InputOutput" >}}

[LogonTypes]: {{< url path="MSDocs.Windows.WindowsServer.LogonTypes" >}}
[System.Enum]: {{< url path="MSDocs.DotNet.Api.System.Enum.MainDoc" >}}

[Working with Enums]: {{< url path="Cortex.Reference.Concepts.WorkingWith.Enums.MainDoc" >}}
[Explicit Casting]: {{< url path="Cortex.Reference.Concepts.WorkingWith.Objects.ObjectCasting.ExplicitCast" >}}

[String]: {{< url path="Cortex.Reference.DataTypes.Text.String.MainDoc" >}}
[Int32]: {{< url path="Cortex.Reference.DataTypes.Numbers.Int32.MainDoc" >}}
[Formatting enumeration values]: {{< url path="MSDocs.DotNet.Api.System.Enum.FormattingEnumerationValues" >}}
[Convert Object To Text]: {{< url path="Cortex.Reference.Blocks.Objects.ConvertObject.ConvertObjectToText.MainDoc" >}}
[Convert Object To Json]: {{< url path="Cortex.Reference.Blocks.Json.ConvertJson.ConvertObjectToJson.MainDoc" >}}
[Working with Enums]: {{< url path="Cortex.Reference.Concepts.WorkingWith.Enums.MainDoc" >}}
[Explicit Casting]: {{< url path="Cortex.Reference.Concepts.WorkingWith.Objects.ObjectCasting.ExplicitCast" >}}
[Enum.Parse]: {{< url path="MSDocs.DotNet.Api.System.Enum.Parse" >}}
[Enum.ToObject]: {{< url path="MSDocs.DotNet.Api.System.Enum.ToObject" >}}
[Enum.ToString]: {{< url path="MSDocs.DotNet.Api.System.Enum.ToString" >}}
[Convert.ToInt32]: {{< url path="MSDocs.DotNet.Api.System.Convert.ToInt32" >}}
[Convert.ToString]: {{< url path="MSDocs.DotNet.Api.System.Convert.ToString" >}}
[LogonType]: {{< url path="Cortex.Reference.DataTypes.Credentials.LogonType.MainDoc" >}}
[UserCredentials]: {{< url path="Cortex.Reference.DataTypes.Credentials.UserCredentials.MainDoc" >}}

[Instantiating an enumeration type]: {{< url path="MSDocs.DotNet.Api.System.Enum.InstantiatingAnEnum" >}}
[Formatting enumeration values]: {{< url path="MSDocs.DotNet.Api.System.Enum.FormattingEnumerationValues" >}}
Loading

0 comments on commit 4f634de

Please sign in to comment.