- Add 07-03-SUMMARY.md with implementation details and decisions - Update STATE.md: progress 54%, decisions, session, metrics - Update ROADMAP.md: phase 07 now 2/8 summaries
70 lines
3.0 KiB
Markdown
70 lines
3.0 KiB
Markdown
---
|
|
phase: 07-user-access-audit
|
|
plan: 03
|
|
subsystem: graph-user-search-service
|
|
tags: [graph-api, user-search, people-picker, services]
|
|
dependency_graph:
|
|
requires: [07-01]
|
|
provides: [GraphUserSearchService]
|
|
affects: [07-04, 07-05]
|
|
tech_stack:
|
|
added: []
|
|
patterns: [Microsoft Graph SDK, OData filter, startsWith, ConsistencyLevel=eventual]
|
|
key_files:
|
|
created:
|
|
- SharepointToolbox/Services/GraphUserSearchService.cs
|
|
modified: []
|
|
decisions:
|
|
- "Minimum 2-character query guard prevents overly broad Graph API requests"
|
|
- "Single-quote escaping in OData filter prevents injection (replace ' with '')"
|
|
- "ConsistencyLevel=eventual + Count=true both required for startsWith on directory objects"
|
|
metrics:
|
|
duration_minutes: 2
|
|
completed_date: "2026-04-07"
|
|
tasks_completed: 1
|
|
files_created: 1
|
|
files_modified: 0
|
|
---
|
|
|
|
# Phase 7 Plan 03: GraphUserSearchService Implementation Summary
|
|
|
|
**One-liner:** GraphUserSearchService implements IGraphUserSearchService using GraphClientFactory, querying Graph /users with startsWith OData filter on displayName, mail, and UPN for people-picker autocomplete.
|
|
|
|
## What Was Built
|
|
|
|
**GraphUserSearchService.cs** — Concrete implementation of IGraphUserSearchService. Queries the Microsoft Graph `/users` endpoint using OData `startsWith` filter across three fields (displayName, mail, userPrincipalName). Sets the required `ConsistencyLevel: eventual` header and `$count=true` parameter mandatory for advanced directory filters. Returns up to `maxResults` (default 10) `GraphUserResult` records ordered by displayName. Guards against queries shorter than 2 characters to prevent broad, wasteful API calls.
|
|
|
|
## Tasks
|
|
|
|
| # | Task | Status | Commit |
|
|
|---|------|--------|--------|
|
|
| 1 | Implement GraphUserSearchService | Done | 026b829 |
|
|
|
|
## Decisions Made
|
|
|
|
1. **2-character minimum guard** — Queries of 0 or 1 character return an empty list immediately without calling Graph. This prevents overly broad results and unnecessary API calls while the user is still typing.
|
|
|
|
2. **OData single-quote escaping** — Query strings replace `'` with `''` before embedding in the OData filter. This prevents OData injection if user input contains apostrophes (e.g., "O'Brien").
|
|
|
|
3. **ConsistencyLevel=eventual + Count=true** — Microsoft Graph requires both headers when using `startsWith` on directory objects. Omitting either causes a 400 Bad Request. Both are set together in the request configuration.
|
|
|
|
## Deviations from Plan
|
|
|
|
None — plan executed exactly as written.
|
|
|
|
## Verification
|
|
|
|
- `dotnet build SharepointToolbox/SharepointToolbox.csproj` — 0 errors, 0 warnings
|
|
- GraphUserSearchService.cs implements IGraphUserSearchService confirmed
|
|
- Uses GraphClientFactory.CreateClientAsync for auth (not raw HTTP)
|
|
- Empty/short query guard (length < 2) returns Array.Empty<GraphUserResult>()
|
|
- Filter covers displayName, mail, and userPrincipalName with startsWith
|
|
|
|
## Self-Check: PASSED
|
|
|
|
Files confirmed present:
|
|
- FOUND: SharepointToolbox/Services/GraphUserSearchService.cs
|
|
|
|
Commits confirmed:
|
|
- FOUND: 026b829
|