The potential issue is the searchFlags value on the custom attributes. adprep /forestprep schema update can alter or replace the searchFlags configuration associated with custom attributes. The attributes themselves can remain intact while losing an indexing-related flag that the legacy application depends on.
Check the affected attribute definitions under Active Directory Schema or query them with PowerShell/ADSI and compare their searchFlags values with a known-good environment or backup. In particular, determine whether the attribute has the appropriate indexing bit enabled. The searchFlags attribute is a bitmask, so you should not just replace the entire value without checking what other flags are already set.
For example, you can inspect an attribute with:
Get-ADObject
If the required indexing flag was lost, correct the schema attribute definition, not each individual user object. After changing searchFlags, allow AD replication to complete and then verify the application's LDAP queries. Also check whether the application is relying on ANR (Ambiguous Name Resolution) or another specific search behavior, because not every searchFlags setting means "indexed." The exact bit that needs to be restored depends on what the application's LDAP query is doing.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin