Skip to content

Split a Windows identity name

Split a DOMAIN\user identity name into domain and account parts, triggered when caller has an authenticated IIdentity and needs the bare account name or the domain.

Field Value
Operation ID OP-030
Trigger Caller has an authenticated IIdentity and needs the bare account name or the domain
Inputs IIdentity
Outputs string
Primary components SecurityPrincipalExtensions.UserId(this IIdentity)`, `SecurityPrincipalExtensions.Domain(this IIdentity)
Entry point Common/SAIF.Common/Extensions/SecurityPrincipalExtensions.cs

Steps

  1. Split identity.Name on the backslash character. (BR-071)
  2. UserId returns the last element (the account portion of DOMAIN\user), or null if the name is empty. (BR-071)
  3. Domain returns the first element (the domain portion), or null if the name is empty. (BR-071)

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start(["Caller has an authenticated<br>IIdentity and needs the<br>account name or domain"]) --> S1["Split identity.Name<br>on backslash character"]
    S1 --> D1{"Which accessor<br>is called?"}
    D1 -->|UserId| D2{"Name is empty?"}
    D2 -->|Yes| R1(["Return null"])
    D2 -->|No| R2(["Return last element<br>(account portion)"])
    D1 -->|Domain| D3{"Name is empty?"}
    D3 -->|Yes| R3(["Return null"])
    D3 -->|No| R4(["Return first element<br>(domain portion)"])
    R1 --> End([Done])
    R2 --> End
    R3 --> End
    R4 --> End

Failure and edge-case behavior

  • These are string-parsing helpers only. They perform no authentication, no group lookup, and no authorization decision.

Sources

  • Common/SAIF.Common/Extensions/SecurityPrincipalExtensions.cs