Skip to content

Validate Graph response in Entra photo sync + consolidate scripts (#224)#257

Open
theneiljohnson wants to merge 1 commit intomicrosoft:masterfrom
theneiljohnson:fix-entra-photo-sync
Open

Validate Graph response in Entra photo sync + consolidate scripts (#224)#257
theneiljohnson wants to merge 1 commit intomicrosoft:masterfrom
theneiljohnson:fix-entra-photo-sync

Conversation

@theneiljohnson
Copy link
Copy Markdown
Collaborator

Resolves #224.

Why @56122's photo file was a few hundred bytes

The legacy downloadEntraPhoto.sh piped whatever Microsoft Graph returned straight to PhotoID.jpg with no HTTP-status or content-type check:

curl -s --location --request GET "$photoURL" --header "$headers2" --output $pathPhoto

When Graph returned an error body — 404 ImageNotFound, 400 Bad Request after a tenant-side change, etc. — the JSON error response was saved as the user's photo. That presents exactly as the report: a tiny non-image file in the user profile.

downloadEntraPhoto_v2.0.0.sh (already in the same folder) fixes all of this — HTTP-code check, file -b --mime-type validation, proper exit codes — but it was a parallel file with no signposting from the readme, so anyone deployed on the original filename never benefited.

Fix

  • Replace downloadEntraPhoto.sh content with the v2.0.0 code so existing Intune deployments self-heal on next sync without anyone having to repoint their script assignment.
  • Remove the duplicate downloadEntraPhoto_v2.0.0.sh.
  • Readme updated: links the script by name, drops the brittle "edit lines 22, 23, 24" pointer, and adds a short note explaining the no-photo / error-response behaviour with a back-reference to M365 Entra Sync Photo #224.

Resolves microsoft#224.

The legacy downloadEntraPhoto.sh wrote whatever Graph returned
straight to PhotoID.jpg with no HTTP-status or content-type check.
When Graph returned an error body (404 ImageNotFound, 400 etc.) the
JSON error response was saved as the user's photo - which presented
exactly as microsoft#224 describes: "the jpg appears in the user profile but
is a matter of a few hundred bytes and doesn't appear to be a proper
jpg".

The downloadEntraPhoto_v2.0.0.sh script already in this folder fixes
all of this (HTTP code check, MIME-type validation via 'file -b
--mime-type', proper exit codes, structured logging) but it was a
parallel file with no signposting from the readme, so anyone deployed
on the original filename never benefited from the fix.

Changes:

- Replace downloadEntraPhoto.sh contents with the v2.0.0 code so
  existing Intune deployments self-heal on next sync without anyone
  having to repoint their script assignment.
- Remove the now-redundant downloadEntraPhoto_v2.0.0.sh duplicate.
- Update the readme to link the script by name, drop the brittle
  "edit lines 22, 23, 24" instruction (line numbers no longer match)
  and add a short note explaining the no-photo / error-response
  behaviour, with a back-reference to microsoft#224.
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.

M365 Entra Sync Photo

1 participant