Skip to content

Support ms-DS-ConsistencyGuid as LDAP sync_field#24367

Merged
cedric-anne merged 1 commit into
glpi-project:mainfrom
danicouso:feature/24332-ms-ds-consistencyguid
Jun 1, 2026
Merged

Support ms-DS-ConsistencyGuid as LDAP sync_field#24367
cedric-anne merged 1 commit into
glpi-project:mainfrom
danicouso:feature/24332-ms-ds-consistencyguid

Conversation

@danicouso

Copy link
Copy Markdown

Checklist before requesting a review

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

Closes #24332

AuthLDAP only handled the attribute named objectGUID when reading and searching binary GUID values. Any other binary GUID attribute used as sync_field was stored and shown as raw bytes, and user lookups against it returned no results because the LDAP filter was not hex-escaped.

ms-DS-ConsistencyGuid has the same binary layout as objectGUID and is the immutable anchor used in Entra ID Connect hybrid setups, where it survives inter-forest migrations that objectGUID does not.

Changes

The conversion now applies to a small case-insensitive list of binary GUID attribute names (objectguid, ms-ds-consistencyguid) in two places:

  • searchUserDn() — the value is hex-escaped before building the LDAP filter, so the directory search actually matches. Without this, user import and synchronization by ms-DS-ConsistencyGuid return no results.
  • getFieldValue() — the value read back from the directory is converted to the canonical GUID string for display and storage.

Attribute names are matched case-insensitively per RFC 4512.

Tests

Added to tests/LDAP/AuthLdapTest.php, alongside the existing testGetFieldValue() and testGuidToHex() (both kept untouched as non-regression checks):

  • testGetFieldValueConvertsObjectGuidBinary — existing objectGUID conversion still works on binary input.
  • testGetFieldValueConvertsMsDsConsistencyGuid — the new attribute.
  • testGetFieldValueIsCaseInsensitiveForGuidAttributes — mixed-case name, as it appears in Microsoft documentation.
  • testGetFieldValueDoesNotDoubleConvertGuidString — values already in GUID string form are returned unchanged.
  • testGuidToHexForBinaryGuidSearch — the hex-escaped form searchUserDn() builds for the LDAP filter.

Verified against a real directory

Tested on a GLPI 11.0.7 instance against an Active Directory with ms-DS-ConsistencyGuid populated on user objects, with the LDAP sync_field set to that attribute.

Before — the value is stored and shown as raw bytes in the LDAP information tab:

image

After — the same value is rendered as a canonical GUID string:

image

User synchronization — users are correctly imported and synchronized using ms-DS-ConsistencyGuid as sync_field:

image image

Out of scope

  • objectSid uses a different binary layout (SID → SDDL) and would need its own decoder. Happy to address in a follow-up if there is interest.

Local checks

  • php -l clean on both files.
  • php-cs-fixer fix --dry-run clean against the project config.
  • phpstan analyze src/AuthLDAP.php clean.

AI-assisted: used an LLM to verify code references and draft the wording; all logic reviewed and authored by me.

AuthLDAP only handled the attribute named objectGUID when reading and
searching binary GUID values. Any other binary GUID attribute used as
sync_field was stored and shown as raw bytes, and user lookups against
it returned no results because the LDAP filter was not hex-escaped.

ms-DS-ConsistencyGuid has the same binary layout as objectGUID and is
the immutable anchor used in Entra ID Connect hybrid setups, where it
survives inter-forest migrations that objectGUID does not.

The conversion now applies to a small list of binary GUID attribute
names in both places: when building the LDAP search filter and when
reading the value back from the directory.

Signed-off-by: Daniel <daniel@ticgal.com>

@cconard96 cconard96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't have the type of environment needed to fully test this, but it seems OK.

@cedric-anne cedric-anne added this to the 11.0.8 milestone Jun 1, 2026
@cedric-anne cedric-anne merged commit 8143211 into glpi-project:main Jun 1, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants