Skip to content

Ldap pagination#22

Open
f2cmb wants to merge 11 commits into
mainfrom
feature/ldap-pagination
Open

Ldap pagination#22
f2cmb wants to merge 11 commits into
mainfrom
feature/ldap-pagination

Conversation

@f2cmb

@f2cmb f2cmb commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.
  • This change requires a documentation update.

Description

Fetch the full LDAP result set page by page (LDAP_CONTROL_PAGEDRESULTS) instead of a single capped search, and flag truncated/incomplete searches via ldap_complete.

Refactors performLdapSearch() into small, tested pieces (connectToLdap / getPageSize / fetchLdapPage / collectAllPages). Honours the AuthLDAP page-size config; mirrors core AuthLDAP::searchForUsers().

Base: sync/boostrap (stacked).

f2cmb added 11 commits June 11, 2026 16:18
- ajax/syncexecute.php: import Safe\session_write_close and narrow POST id with is_numeric before int cast (avoids cast.int on mixed)
- src/Inventory/LdapSyncExecutor.php, src/SyncFilter.php: rector FlipTypeControlToUseExclusiveTypeRector + NewlineAfterStatementRector
- front/authldapsyncfilter.form.php: drop always-true null guard and ignore argument.type on add() (phpstan drift from GLPI core bump)
Critical:
- SyncFilter: use AuthLDAP field 'deref_option' (not 'deref', which never
  exists and silently fell back to 0); robust is_numeric cast in both spots.

Major:
- LdapSyncExecutor: stop silently returning empty results — log + skipped++
  when a SyncFilter has no linked AuthLDAP (executeSingleFilter) and log the
  null-AuthLDAP/null-builder preview paths. Prevents a false 'disappeared'
  signal for future lifecycle handling.
- LdapSyncExecutor::replacePlaceholders: substitute LDAP values inside the PHP
  structure (string leaves only) instead of into a re-serialized JSON string
  with a hand-rolled addcslashes escaper. Closes JSON key-injection and
  control-character corruption from attacker-controlled LDAP values.
- AuthLdapSyncFilter::prepareInputForAdd: whitelist the two relation foreign
  keys (array_intersect_key) to prevent mass assignment.
- SyncFilter::showBuilderMappingTab: render alerts via a Twig partial using
  core alerts_macros and pass Monaco CSS as a template var instead of echoing
  raw HTML from a class method.
- LdapSyncExecutor: trim verbose narrating class PHPDoc.

Tests:
- previewSyncFilter without linked AuthLDAP (result + log);
- replacePlaceholders cannot inject inventory keys / preserves control chars;
- prepareInputForAdd strips unknown keys.

Note: Hooks::CSRF_COMPLIANT intentionally NOT added — deprecated since GLPI
11.0 (CSRF enforced by CheckCsrfListener); declaring it would fail phpstan.
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.

Support LDAP paged results in LdapSyncExecutor

1 participant