Skip to content

Conversation

anishapant21
Copy link
Collaborator

@anishapant21 anishapant21 commented Jul 30, 2025

DONE

  • Mapped the WebChart MySQL schema to the LDAP-required schema.
  • Integrated observation code ("LDAP UID Number") lookup from WebChart DB to map uidNumber values.
  • Ensured that if multiple observation values exist, the latest entry is selected for uidNumber.
  • Preserved fallback to users.user_id + 10000 when no observation code value is present.
  • Added logic to derive gidNumber from the realms.id field in the WebChart DB.
  • Introduced an offset of +10000 to both uidNumber and gidNumber to avoid collisions with system accounts.

@anishapant21 anishapant21 linked an issue Aug 4, 2025 that may be closed by this pull request
@anishapant21 anishapant21 requested a review from Copilot August 6, 2025 14:08
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR maps the existing WebChart MySQL schema to LDAP-required format by updating field mappings and adding numeric ID derivation logic.

  • Derives uidNumber and gidNumber from WebChart database fields (user_id and realm id) with +10000 offset
  • Updates LDAP user entry creation to use WebChart schema fields (first_name, last_name, email)
  • Refactors MySQL queries to work with WebChart's users, realms, and user_realms tables

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
src/utils/ldapUtils.js Maps WebChart user fields to LDAP entry format and derives numeric IDs
src/db/drivers/mysql.js Updates database queries to use WebChart schema tables and relationships

Copy link

@runleveldev runleveldev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this merging as-is, but I don't want to close the related Issue until we can figure out chart types with observations for at least uidNumber and gidNumber

@anishapant21
Copy link
Collaborator Author

Created a new observation code "LDAP UID Number" and assigned a user two values. Added logic to get the first value and map as the uidNumber.

Webchart:
Screenshot 2025-08-21 at 12 10 33 PM

ldapsearch:
ldap-map

@anishapant21 anishapant21 changed the base branch from fixes/group-search-and-gid to main August 21, 2025 16:31
const uidNumber = user.uid_number !== undefined && user.uid_number !== null ? user.uid_number.toString() : "0";
const gidNumber = user.gid_number !== undefined && user.gid_number !== null ? user.gid_number.toString() : "0";
// 1) Prefer observation-mapped UID (ldap_uid_number)
// 2) Fallback: old behavior (user_id + 10000)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to worry about maintaining this compatibility. It should log a warning if the user entry in webchart doesn't have a matching uid observation and either return a LDAP entry without a uidNumber or fail and return no entry.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, uidNumber is a MUST for posixAccount in the LDAP schema. As such, a user that doesn't have a uidNumber observation should be considered invalid and no entry should ever be returned for them. This also has the benefit of giving an implicit way to distinguish between LDAP and non-LDAP users in the Webchart system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Webchart Integration
2 participants