Skip to content

feat(graph): [k6-test][OCISDEV-1671] show school role and home school in sharee search - #13618

Open
gauravsoni119 wants to merge 4 commits into
masterfrom
feat/OCISDEV-1671-school-role-in-sharee-search
Open

gauravsoni119 wants to merge 4 commits into
masterfrom
feat/OCISDEV-1671-school-role-in-sharee-search

Conversation

@gauravsoni119

@gauravsoni119 gauravsoni119 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

The Graph user search, used by the share dialog in Drive and Safe, can now show a sharee's school role ("Teacher"/"Student", translated) and home-school number as the second line of each result, e.g. max.muster · Teacher · 1234. Administrators opt in by listing the new values schoolRole and homeSchool in OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES. Two new settings control the role: GRAPH_USER_SEARCH_SCHOOL_ROLE_MAPPING maps directory values to teacher/student, and GRAPH_LDAP_USER_SCHOOL_ROLE_ATTRIBUTE (default userClass) names the LDAP attribute to read. Without these settings, the search behaves exactly as before.

Related Issue

  • Fixes: OCISDEV-1671

Motivation and Context

The second line only repeated the name and showed "Member", so with many identical names sharers couldn't tell students from teachers or see which school a person belongs to.

How Has This Been Tested?

  1. In the ocis_multi example, set OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES=onPremisesSamAccountName,schoolRole,homeSchool, GRAPH_USER_SEARCH_SCHOOL_ROLE_MAPPING=ocisSpaceAdmin:teacher,ocisAdmin:teacher,ocisUser:student and GRAPH_LDAP_USER_SCHOOL_ROLE_ATTRIBUTE=ownCloudRole, then search kat in the share dialog: the result shows katherine · Teacher · ocis.
  2. Log in as a Space Admin and search marie@ocis.ocm.owncloud.test: the result shows marie · Student · ocis.ocm, with the other instance as her home school.
  3. Search adm: the result shows admin · Teacher and no school, because the master ID doesn't resolve to an instance.
  4. Remove the three settings and search again: no second line appears for non-admins, and the response has "attributes": [], as before.

Screenshots (if appropriate):

N.A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@gauravsoni119
gauravsoni119 requested a review from a team as a code owner November 30, 2026 14:48
@gauravsoni119 gauravsoni119 added the Status:Needs-Review Needs review from a maintainer label Nov 30, 2026
@gauravsoni119 gauravsoni119 self-assigned this Nov 30, 2026
@kw-security

kw-security commented Nov 30, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gauravsoni119
gauravsoni119 force-pushed the feat/OCISDEV-1671-school-role-in-sharee-search branch from 7190089 to dc169bf Compare December 1, 2026 15:25
Comment thread services/graph/pkg/service/v0/users.go Outdated
for _, u := range users {
ids = append(ids, u.GetId())
}
schoolInfoByID, err := g.identityBackend.GetSchoolInfo(ctx, ids)

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.

Have you checked how much this affects search speed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for raising this. I hadn't measured it before, so I did now on the ocis_multi example (OpenLDAP, 206 users). The search returned 200 results, as a non-admin caller, with 10 warm-up + 100 timed requests per run:

median p95
settings off (3 runs) 89.2 / 91.1 / 91.1 ms 106 / 124 / 117 ms
schoolRole + homeSchool on (2 runs) 94.0 / 93.4 ms 109 / 112 ms

That's about +3 ms (~3%) on the median for 200 results; p95 is within noise.

Why it stays small:

  • The school info is fetched with one batched LDAP query for all result users (OR filter on the user ID, 3 attributes), not one query per user.
  • The school number goes through the existing cached instance mapper, so usually there's no extra lookup.
  • The caller's locale is resolved once per request.
  • Nothing runs unless schoolRole or homeSchool is listed in OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES.

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.

Could you run k6 load test against a branch?

@gauravsoni119 gauravsoni119 Dec 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Could you run k6 load test against a branch?

The k6 pipeline is green: https://github.com/owncloud/ocis/actions/runs/47070783434

@gauravsoni119
gauravsoni119 requested a review from 2403905 December 3, 2026 07:24
@gauravsoni119
gauravsoni119 force-pushed the feat/OCISDEV-1671-school-role-in-sharee-search branch from dc169bf to c8d9276 Compare December 3, 2026 08:29
@2403905 2403905 changed the title feat(graph): [OCISDEV-1671] show school role and home school in sharee search feat(graph): [k6][OCISDEV-1671] show school role and home school in sharee search Dec 3, 2026
@2403905 2403905 changed the title feat(graph): [k6][OCISDEV-1671] show school role and home school in sharee search feat(graph): [k6-loadtest][OCISDEV-1671] show school role and home school in sharee search Dec 3, 2026
@2403905 2403905 changed the title feat(graph): [k6-loadtest][OCISDEV-1671] show school role and home school in sharee search feat(graph): [k6-load-test][OCISDEV-1671] show school role and home school in sharee search Dec 3, 2026
@gauravsoni119 gauravsoni119 changed the title feat(graph): [k6-load-test][OCISDEV-1671] show school role and home school in sharee search feat(graph): [k6-test][OCISDEV-1671] show school role and home school in sharee search Dec 3, 2026
@gauravsoni119
gauravsoni119 force-pushed the feat/OCISDEV-1671-school-role-in-sharee-search branch from c8d9276 to 5cf8553 Compare December 3, 2026 14:24

@2403905 2403905 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.

Review

I read the diff only. I did not run the tests or the build.

Important

  1. services/graph/pkg/service/v0/users.go (schoolAttributes): A failure of the batched school lookup is hidden.
    • The code logs the error at Debug level.
    • The handler returns 200 without schoolRole and homeSchool.
    • A large user list creates one very large LDAP filter. The server can reject it.
    • Fix: log at Warn level. Split the user IDs into chunks of 100 to 200.

Minor

  1. services/graph/pkg/config/config.go: The description of GRAPH_USER_SEARCH_SCHOOL_ROLE_MAPPING names the attribute userClass.
    • GRAPH_LDAP_USER_SCHOOL_ROLE_ATTRIBUTE can change this attribute.
    • Fix: refer to the configured attribute in the description.
  2. services/graph/pkg/config/config.go: The description of OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES does not list the prerequisites of homeSchool.
    • homeSchool is empty when InstanceURLTemplate or CrossInstanceReferenceTemplate is not set.
    • homeSchool is also empty when OCIS_LDAP_INSTANCE_MAPPER_ENABLED is false.
    • Fix: list these prerequisites in the description.
  3. services/graph/pkg/identity/ldap.go (GetSchoolInfo): The attribute list always contains userMemberAttribute. This value can be an empty string.
    • Some LDAP servers reject an empty attribute name.
    • Fix: add the attribute only when it is not empty.
  4. services/graph/pkg/identity/ldap.go (resolveMemberInstanceName): The function logs a Warn line for each unresolvable member value.
    • GetSchoolInfo calls it for each user in each search. The log can fill up.
    • Fix: log at Debug level in this path.
  5. services/graph/pkg/service/v0/users.go: schoolAttributes runs before filterOutPrivateUserAttrs.
    • Users with only the identity-search permission also get schoolRole and homeSchool.
    • Please confirm that this is intended. Document it in the changelog.

@gauravsoni119
gauravsoni119 force-pushed the feat/OCISDEV-1671-school-role-in-sharee-search branch from 5cf8553 to 83e3c73 Compare December 4, 2026 07:09
@gauravsoni119

Copy link
Copy Markdown
Contributor Author

Review

I read the diff only. I did not run the tests or the build.

Important

  1. services/graph/pkg/service/v0/users.go (schoolAttributes): A failure of the batched school lookup is hidden.

    • The code logs the error at Debug level.
    • The handler returns 200 without schoolRole and homeSchool.
    • A large user list creates one very large LDAP filter. The server can reject it.
    • Fix: log at Warn level. Split the user IDs into chunks of 100 to 200.

Minor

  1. services/graph/pkg/config/config.go: The description of GRAPH_USER_SEARCH_SCHOOL_ROLE_MAPPING names the attribute userClass.

    • GRAPH_LDAP_USER_SCHOOL_ROLE_ATTRIBUTE can change this attribute.
    • Fix: refer to the configured attribute in the description.
  2. services/graph/pkg/config/config.go: The description of OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES does not list the prerequisites of homeSchool.

    • homeSchool is empty when InstanceURLTemplate or CrossInstanceReferenceTemplate is not set.
    • homeSchool is also empty when OCIS_LDAP_INSTANCE_MAPPER_ENABLED is false.
    • Fix: list these prerequisites in the description.
  3. services/graph/pkg/identity/ldap.go (GetSchoolInfo): The attribute list always contains userMemberAttribute. This value can be an empty string.

    • Some LDAP servers reject an empty attribute name.
    • Fix: add the attribute only when it is not empty.
  4. services/graph/pkg/identity/ldap.go (resolveMemberInstanceName): The function logs a Warn line for each unresolvable member value.

    • GetSchoolInfo calls it for each user in each search. The log can fill up.
    • Fix: log at Debug level in this path.
  5. services/graph/pkg/service/v0/users.go: schoolAttributes runs before filterOutPrivateUserAttrs.

    • Users with only the identity-search permission also get schoolRole and homeSchool.
    • Please confirm that this is intended. Document it in the changelog.

Thanks for the review! All addressed in 83e3c73:

  1. The school lookup now runs in chunks of 200 IDs (schoolInfoBatchSize), so large searches no longer build one huge filter. A failed lookup is logged at Warn in the handler, and the search still returns its results without the two values.
  2. The mapping description now refers to the attribute set by GRAPH_LDAP_USER_SCHOOL_ROLE_ATTRIBUTE (default userClass).
  3. The OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES description now lists the homeSchool prerequisites: both instance templates set and the instance mapper enabled.
  4. The member attribute is only requested when it's configured; no empty attribute name anymore.
  5. Unresolvable member values are logged at Debug in the school lookup; the existing cross-instance reference code keeps its Warn.
  6. Yes, that's intended: sharers should see role and school, the same as the other displayed attributes, which are also computed before filterOutPrivateUserAttrs. I've added a sentence about it to the changelog.

@gauravsoni119
gauravsoni119 requested a review from 2403905 December 4, 2026 07:31
…e search

The share dialog's user search showed the name twice plus "Member", so sharers
couldn't tell students from teachers or see their school. Graph can now add a
translated school role and the home-school number to each result, enabled
through OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES.

Signed-off-by: Gaurav Soni <sonigaurav119@gmail.com>
Large user searches no longer build one huge LDAP filter: the school lookup now
queries in chunks of 200 IDs. A failed lookup is logged as a warning, unresolved
schools no longer warn on every search, and the setting descriptions now state
the configurable role attribute and what the home school needs.

Signed-off-by: Gaurav Soni <sonigaurav119@gmail.com>
@gauravsoni119
gauravsoni119 force-pushed the feat/OCISDEV-1671-school-role-in-sharee-search branch from 83e3c73 to 622c1ed Compare December 4, 2026 08:25
@2403905

2403905 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

@gauravsoni119 Please check if the school data can come from the main user search. Then GetSchoolInfo does not need its own LDAP search.

Why this seems possible

  1. The sharee search calls GetUsers. It calls FilterUsers in services/graph/pkg/identity/ldap.go. This sends one LDAP search.
  2. The attribute list getUserAttrTypesForSearch() already contains userMemberAttribute. Each result entry already has the home school value.
  3. createUserModelFromLDAP already resolves this value to an instance name. It uses the cached getInstanceName.
  4. Only the school role attribute (userClass by default) is missing. Add userAttributeMap.schoolRoleAttribute to the same attribute list.
  5. The $filter path ends in identityBackend.FilterUsers in services/graph/pkg/service/v0/users_filter.go. It uses the same search code.

What blocks it

  • libregraph.User has no field for the role or the school.
  • Suggested fix: the backend returns the users and a map[string]SchoolInfo. usersFromLDAPEntries fills the map from the entries that it already has.
  • This changes the Backend interface. The CS3 backend and the mocks need the same change.

What you get

  • One LDAP search for each request, not two.
  • No batched filter with all user IDs. This also removes the filter size risk from my earlier review comment.

Please check

  1. Does the GetPreciseUser path use an attribute list that contains the school role attribute? I did not verify this.
  2. Is there a reason to keep the second search? For example, a search that does not return userClass for some users.

…earch

The school role and home school now come from the LDAP entries the user search
already fetches, through a request-scoped collector, instead of a second batched
lookup. Every search route makes one LDAP query, the role attribute is only
requested when the response shows it, and the identity backend interface is
unchanged from master.

Signed-off-by: Gaurav Soni <sonigaurav119@gmail.com>
@gauravsoni119

Copy link
Copy Markdown
Contributor Author

@gauravsoni119 Please check if the school data can come from the main user search. Then GetSchoolInfo does not need its own LDAP search.

Why this seems possible

  1. The sharee search calls GetUsers. It calls FilterUsers in services/graph/pkg/identity/ldap.go. This sends one LDAP search.
  2. The attribute list getUserAttrTypesForSearch() already contains userMemberAttribute. Each result entry already has the home school value.
  3. createUserModelFromLDAP already resolves this value to an instance name. It uses the cached getInstanceName.
  4. Only the school role attribute (userClass by default) is missing. Add userAttributeMap.schoolRoleAttribute to the same attribute list.
  5. The $filter path ends in identityBackend.FilterUsers in services/graph/pkg/service/v0/users_filter.go. It uses the same search code.

What blocks it

  • libregraph.User has no field for the role or the school.
  • Suggested fix: the backend returns the users and a map[string]SchoolInfo. usersFromLDAPEntries fills the map from the entries that it already has.
  • This changes the Backend interface. The CS3 backend and the mocks need the same change.

What you get

  • One LDAP search for each request, not two.
  • No batched filter with all user IDs. This also removes the filter size risk from my earlier review comment.

Please check

  1. Does the GetPreciseUser path use an attribute list that contains the school role attribute? I did not verify this.
  2. Is there a reason to keep the second search? For example, a search that does not return userClass for some users.

thanks! Done in bf17930, with one adjustment: the Safe search uses $filter=vaultEligible eq true, which goes through applyUserFilter and combines several backend calls, so returning a map from the search methods would have to be threaded through all of it.

Instead, GetUsers puts a request-scoped collector into the context (only when schoolRole/homeSchool is displayed), and the LDAP backend fills it from the entries the search already fetches. The role attribute is only requested when a collector is present, GetSchoolInfo and the batching are gone, and the Backend interface is unchanged from master.

A user who is a member of several schools now always shows the same home school,
the smallest resolved school number, instead of whichever value the directory
returned first. The school-info collector also no longer lets an empty value
replace one that was already recorded for the same user.

Signed-off-by: Gaurav Soni <sonigaurav119@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status:Needs-Review Needs review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants