optimize IDNumber selection, avoid conflicts, remove site vars, rewrite custom mapping, add tests#286
Merged
simonLeary42 merged 1 commit intomainfrom Sep 12, 2025
Merged
Conversation
634686d to
2d2072c
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the UID/GID allocation system to eliminate conflicts by checking IDs across the entire LDAP tree instead of specific OUs, and removes the SQL-based site variables system in favor of configuration-based offset values.
- Replaces SQL
sitevarstable with configuration-based offset values for different ID ranges - Optimizes LDAP queries to check for ID conflicts tree-wide instead of per-OU
- Removes iterative ID checking in favor of single LDAP query with array operations
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/docker-dev/sql/bootstrap.sql | Removes sitevars table creation and related indexes |
| resources/lib/UnitySQL.php | Removes getSiteVar and updateSiteVar methods and table constant |
| resources/lib/UnityLDAP.php | Refactors ID allocation with tree-wide conflict checking and configuration offsets |
| resources/lib/UnityGroup.php | Updates PI group creation to use new LDAP method signature |
| resources/init.php | Adds new offset parameters to UnityLDAP constructor |
| defaults/config.ini.default | Adds offset configuration values for different ID ranges |
| README.md | Documents migration steps from version 1.2 to 1.3 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
9ed28b1 to
afcd23f
Compare
afcd23f to
bba872f
Compare
ccadb28 to
7d7653c
Compare
Member
Author
|
closes #121 |
45e5098 to
2096454
Compare
bryank-cs
approved these changes
Sep 11, 2025
Contributor
bryank-cs
left a comment
There was a problem hiding this comment.
Couple of optional changes, otherwise looks ok.
01c80f8 to
d2d38fc
Compare
…te custom mapping, add tests
71130e7 to
52914cd
Compare
Closed
Member
Author
Member
Author
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IDNumInUseis extremely wasteful: it queries LDAP for the entireusers,pi_groups, andgroupssubtrees (all attributes) every single iteration while it increments IDNumbers until it finds a free onegetNext{PIGID,ORGGID,UIDGID}Numberquery LDAP one time for just theuidNumberandgidNumberattributes, and use that data for all iterationsIDNumInUsecreated the need for the site vars, they are no longer neededIDNumInUsedid not consider custom mapped IDs or IDNumbers outside theusers,pi_groups, andgroupssubtrees, this is fixedgetNext{PIGID,ORGGID,UIDGID}Numberto avoid giving out custom mapped IDs, the CSV parsing logic fromgetUnassignedIDhas been moved to its own functiongetCustomIDMappingsgetUnassignedIDhas been removed and re-implemented ingetNextUIDGIDNumber$netid = strtok($uid, "_")getNextUIDNumberis nowgetNextUIDGIDNumbergetNextPiGIDNumber->getNextPIGIDNumber(consistent capitalization)ldap.custom_user_mappings_dir, set$_SERVER["HTTP_HOST"]to"phpunit"during unit tests, created a config override calledphpunit, created a user mapping directorytest/custom_user_mapping/, and changedldap.custom_user_mappings_dirtotest/custom_user_mappingin thephpunitconfig override.supercedes #248, #253