I'm trying to change the Query Transform so that I don't include Deactivated users in the result

This is the default value of the Local People Results

{?{searchTerms} ContentClass=urn:content-class:SPSPeople}

What I found so far is that I need to include something like this (&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))

But whatever I try it doesn't work. I double checked that I do have some disabled users in my SharePoint Online solution.

Do anyone know how to combine this 2 into a working one or does anyone else have a working example.

1 Answer 1


You need to use that exclusion in the User Profile Import, not in the search query. Open the User Profile Service application and go to your Sync Connection. Hover and choose to edit the filter. In there you can apply this logic. Once done run a few synchronizations to remove the users from the user profiles.

Then run a full crawl of your Content Source containing the user profile connection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.