Change Active Directory password¶
ChangePassword resets the AD password for a named user identified by user ID — independent of whatever account m_DirUser currently references — and optionally stamps the account's Comment attribute with the identity of who made the change.
| Field | Value |
|---|---|
| Operation ID | OP-SU-06 |
| Trigger | Caller calls clsSystemUser.ChangePassword(inUserId, inNewPwd, [inUpdatedBy]) |
| Inputs | inUserId target user ID; inNewPwd new password value; optional inUpdatedBy updater identity |
| Outputs | Boolean result; updated AD password and, when supplied, updated Comment attribute |
| Primary components | clsSystemUser.ChangePassword(...) |
| Entry point | Business\SAIF.Business.Security.SystemUser\clsSystemUser.vb |
Steps¶
- Resolve the target user.
ChangePasswordcallsm_DirServer.GetUser(inUserId)to locate the account, independent of the object's ownm_DirUsercontext. - Handle a failed lookup. If the user cannot be found,
isValidis set toFalseand no password change is attempted. - Set the new password. If the user is found, a
Tryblock invokesthisUser.m_DirEntry.Invoke("SetPassword", inNewPwd). - Record the updater. If
inUpdatedByis not empty,thisUser.Commentis set to that value in the sameTryblock. - Handle a failed password set. If
SetPassword(or theCommentassignment) raises an exception, it is caught and re-thrown asApplicationException("Unable to set password.", ex)— the caller receives a wrapped exception rather than aFalsereturn for this failure path. - Commit unconditionally. Regardless of whether the
Tryblock succeeded or threw, theFinallyblock callsthisUser.m_DirEntry.CommitChanges(). - Return the outcome. The method returns
isValid. Note thatisValidis only ever explicitly set toFalse(step 2, when the user is not found); it is never set toTrueon the success path, so a successful password reset also returnsFalseunless the caller lookup failed.*
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Caller calls ChangePassword]) --> Lookup[m_DirServer.GetUser inUserId]
Lookup --> Found{User found?}
Found -->|No| Fail([isValid = False; return False])
Found -->|Yes| SetPwd[Invoke SetPassword with inNewPwd]
SetPwd --> UpdatedBy{inUpdatedBy supplied?}
UpdatedBy -->|Yes| SetComment[Set Comment to inUpdatedBy]
UpdatedBy -->|No| Commit
SetComment --> Commit[Finally: CommitChanges]
SetPwd -.exception.-> Throw[Throw ApplicationException]
Commit --> Return([Return isValid - always False on this path*])
Failure and edge-case behavior¶
ChangePasswordreturnsFalsefor both a "user not found" outcome and a successful password reset, because theisValidvariable is never assignedTrueanywhere in the method; callers cannot distinguish success from a not-found condition using the return value alone.*- A failure during
SetPasswordthrows anApplicationExceptionrather than returningFalse, so callers must handle both a thrown exception and aFalsereturn to fully cover this method's failure modes. CommitChanges()runs in theFinallyblock even whenSetPasswordthrew, so a partially-appliedCommentchange (if it executed before the exception) may still be committed.*- The method operates on any user resolvable by
inUserId, not just the object's currently loadedm_DirUser— it does not require Switch active user context to have been called first.
Related documentation¶
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