Member Junction
    Preparing search index...

    Function resolvePrincipalFrom

    • Resolves the principal a configured candidate names, falling back deterministically.

      The ladder, in order:

      1. Name — tried first so that every host resolving today resolves to the SAME user as before. This is what makes adding the Email rung a compatible change rather than a semantic one. ACTIVE only, which is that compatibility claim's one deliberate exception: a host whose setting names a DEACTIVATED user stops resolving to them. That is the point, not a casualty — see below.
      2. Email — the identity column everywhere else in MJServer, and the only one the schema makes unique (UQ_User_Email). This is the rung that resolves MJ's own default. ACTIVE only, for the same reason.
      3. System — by ID, so it survives the system user being renamed. ACTIVE only.
      4. Owner — lowest ID among ACTIVE owners. A last resort, but still deterministic: the previous "first Owner in cache order" made CreatedByUserID depend on the order SELECT * FROM vwUsers happened to return, which is unstable across boots and within a process.

      Every rung breaks ties by lowest ID (lowestActiveById), never by array position, and no rung returns an inactive user — the configured rungs included. An operator naming a user in config is the likeliest way to end up pointed at a disabled account (the admin whose address is in the setting leaves, and their account is deactivated), and honouring it would mean the server keeps provisioning as someone who no longer works there, silently and indefinitely. A guarantee that every rung holds except the two anyone actually configures is not a guarantee.

      Pure, and reports rather than logs, so the caller owns log volume and phrasing.

      Type Parameters

      Parameters

      • candidate: string

        the configured value; blank/undefined means "no preference", not an error

      • users: readonly T[]

        the candidate pool, normally UserCache.Users

      • systemUserId: string

        the deployment's system user ID (UserCache.Instance.SYSTEM_USER_ID)

      Returns PrincipalResolution<T>