WritebackToDFO
Portalldapwritebacktodfo
Description
This script performs a writeback operation to update external identifiers, email addresses, and user IDs in the DFO system. It processes user records from the Portal LDAP and updates the corresponding records in SAP.
Input Parameters
key_field: Enum:username,uh-username,idautoID(optional)key_value: String (optional)process_all: Boolean (optional)log_only: Boolean
Local Variables
sapAnsattBaseUrl: Base URL for SAP API.sapKey: API key for SAP.sapReadOnly: Flag indicating if the operation is read-only.sapWritebackBrukerident: Flag indicating if the employee ID should be written back asbrukerident.sapWritebackBusinessRoleException: List of business roles to be excluded from writeback.actionSetName: Name of the current action set.processedAccounts: Array to keep track of processed accounts.total,totalSkipped,totalUnchanged,totalUpdate,totalUpdateFail: Counters for various operations.
Workflow
-
Initialize Variables
- Set initial values for counters and other variables.
-
Create Connections
- Establish connections to Portal LDAP.
- Error Handling:
- Log errors and invoke
ErrorHandlerif the connection fails.
- Log errors and invoke
- Error Codes:
LDAP_CONNECTION_FAILED: Failed to connect to Portal LDAP.
-
Fetch and Process Records
- Query records based on
key_fieldandkey_valueor process all records. - Error Handling:
- Skip records that are deleted, disabled, missing essential attributes, or not entitled to Active Directory.
- Log errors and increment counters for skipped records.
- Query records based on
-
Create Writeback Record
- Create a record with
eksternIdent,epost, and optionallybrukerident.
- Create a record with
-
Fetch Existing Record from SAP
- Perform an HTTP GET request to fetch the existing record from SAP.
- Error Handling:
- Log errors and invoke
ErrorHandlerif the fetch operation fails. - Error Codes:
SAP_FETCH_FAILED: Failed to fetch the user from SAP.
- Log errors and invoke
-
Check for Changes and Update SAP
- Compare the calculated record with the fetched record from SAP.
- Error Handling:
- Skip updating
brukeridentif it already exists. - Log errors and invoke
ErrorHandlerif the update operation fails. - Error Codes:
SAP_UPDATE_FAILED: Failed to update the user in SAP.
- Skip updating
-
Close Connections
- Close the Portal LDAP connection.
-
Log Results
- Log summaries of operations, including successes and failures.
External Systems and Communications
- SAP: Target system where user records are updated.
- Portal LDAP: Source system for user data.
Response Codes/Outputs
- Error Codes:
LDAP_CONNECTION_FAILED: Failure in connecting to LDAP.SAP_FETCH_FAILED: Failed to fetch the user from SAP.SAP_UPDATE_FAILED: Failed to update the user in SAP.- Other codes as defined in the workflow.
Summary
This script updates external identifiers, email addresses, and user IDs in the DFO system by processing user records from Portal LDAP and updating the corresponding records in SAP. It handles various conditions to ensure accurate and efficient updates while logging all results and errors.
Written by AI (2025-10-30)