Berg Hansen
Portalldaptoberghansen
Description
This script synchronizes user data from a portal directory to Berg Hansen via API. It processes user records, performs necessary transformations, and updates or creates user accounts in Berg Hansen. The script also handles enabling, disabling, and updating user accounts based on specific conditions.
Input Parameters
key_field: Enum:username,uh-username,idautoID(optional)key_value: String (optional)debug: Boolean (optional)log_only: Booleanprocess_all: Boolean (optional)
Local Variables
actionSetName: The name of the current action set.processedAccounts: Array to keep track of processed accounts.total,totalSkipped,totalUnchanged,totalAdd,totalAddFail,totalUpdate,totalUpdateFail,totalDisable,totalDisableFail: Counters for various operations.baseUrl: Base URL for Berg Hansen API.inst: Customer identifier for Berg Hansen.
Workflow
-
Create Connections
- Establish connections to Portal LDAP and fetch session token from Berg Hansen.
- Perform a health check to verify Berg Hansen API is working.
- Error Handling:
- Log errors and invoke
ErrorHandlerif any connection fails.
- Log errors and invoke
- Error Codes:
LDAP_CONNECTION_FAILED: Failed to connect to Portal LDAP.BERG_HANSEN_CONNECTION_FAILED: Failed to connect to Berg Hansen.
-
Fetch and Transform Data
- Fetch all users from Berg Hansen and iterate for matching.
- Query records based on
key_fieldandkey_valueorprocess_all. - Error Handling:
- Log and skip records with missing essential attributes.
-
Perform Berg Hansen Operations
- Disable: Disable users by setting the active flag to false.
- Error Handling:
- Log errors and invoke
ErrorHandleron failure.
- Log errors and invoke
- Error Codes:
BERG_HANSEN_DISABLE_FAILED: Failed to disable a user in Berg Hansen.
- Error Handling:
- Create: Add new users to Berg Hansen.
- Error Handling:
- Log errors and invoke
ErrorHandleron failure.
- Log errors and invoke
- Error Codes:
BERG_HANSEN_CREATE_FAILED: Failed to create a user in Berg Hansen.
- Error Handling:
- Update: Update existing users in Berg Hansen.
- Error Handling:
- Log errors and invoke
ErrorHandleron failure.
- Log errors and invoke
- Error Codes:
BERG_HANSEN_UPDATE_FAILED: Failed to update a user in Berg Hansen.
- Error Handling:
- Disable: Disable users by setting the active flag to false.
-
Close Connections
- Close all established connections.
-
Log Results
- Log summaries of operations, including successes and failures.
External Systems and Communications
- Berg Hansen: Target system where user accounts are managed.
- Portal LDAP: Source system for user data.
Response Codes/Outputs
- Error Codes:
LDAP_CONNECTION_FAILED: Failure in connecting to LDAP.BERG_HANSEN_CONNECTION_FAILED: Failure in connecting to Berg Hansen.BERG_HANSEN_DISABLE_FAILED: Failed to disable a user in Berg Hansen.BERG_HANSEN_CREATE_FAILED: Failed to create a user in Berg Hansen.BERG_HANSEN_UPDATE_FAILED: Failed to update a user in Berg Hansen.
- Success Outputs:
- Log messages confirming the successful addition, update, or disablement of user accounts.
Summary
This script synchronizes user data from a portal directory to Berg Hansen via API. It handles various operations such as creating, updating, and disabling user accounts while logging all results and errors.
Written by AI (2025-10-30)