Skip to content

Switch active user context

LoadThisUser lets a caller redirect the object's active m_DirUser context to a different Active Directory account, reusing the already-bound m_DirServer connection. It is also used internally by UpdateUser (see Create or update an external user) to locate the account being edited before applying field changes.

Field Value
Operation ID OP-SU-03
Trigger Caller calls clsSystemUser.LoadThisUser(InUserId) directly, or UpdateUser(...) calls it internally as its first step
Inputs InUserId — the target user's ID
Outputs Boolean result; on success, m_DirUser is replaced with the located clsUser instance
Primary components clsSystemUser.LoadThisUser(...)
Entry point Business\SAIF.Business.Security.SystemUser\clsSystemUser.vb

Steps

  1. Look up the target user. LoadThisUser calls m_DirServer.GetUser(InUserId) against the directory connection established at construction.
  2. Handle a failed lookup. If the lookup returns Nothing, the method returns False and leaves the existing m_DirUser context untouched.
  3. Switch the active context. If the lookup succeeds, the method sets isOkay = True and replaces m_DirUser with the located clsUser instance.
  4. Return the outcome. The method returns True after the switch, or False if the user could not be found.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Caller calls LoadThisUser with InUserId]) --> Lookup[m_DirServer.GetUser InUserId]
    Lookup --> Found{User found?}
    Found -->|No| Fail([Return False; m_DirUser unchanged])
    Found -->|Yes| Switch[Replace m_DirUser with located clsUser]
    Switch --> Ok([Return True])

Failure and edge-case behavior

  • A failed lookup leaves the previous m_DirUser context intact rather than clearing it, so a caller that ignores the False return value continues operating against the prior user's context.*
  • The method performs no validation on InUserId format before the lookup; malformed IDs simply fail to resolve like any other unmatched ID.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

Sources

  • Business\SAIF.Business.Security.SystemUser\clsSystemUser.vb