I write this query for search user in a site.


The problem is this returns all the user accounts and service accounts. I only want the user accounts. How can i remove the service accounts in people search query?


Create a custom user property of type boolean. For the accounts that don't need to be displayed, set it to true. Map that property to managed property and then use that property as a filter in the REST API like DoNotDisplayInResults = false

Its REST query would be similar to below:


Unfortunately, there is no easy way to filter out service accounts. So we manually set the value in service accounts from User profile service application.

| improve this answer | |
  • is it possible without any modification in the accounts i have right now? i mean any built in properties? – Tarek Salah uddin Mahmud Oct 19 '16 at 13:18
  • You control the accounts. You have to figure this out. DO the service accounts have email addresses? Departments? Managers? If any of these are blank then you can use those attributes. It is different for every company. Since the accounts are seen as users by SharePoint you have to make the determination. – Matthew McDermott Oct 20 '16 at 1:16

It is best to filter them out in the User profile service configuration so they are not even imported from AD. You can write pretty complex LDAP filters right there - then it just depends if they are in some OU, have some attribute set or not...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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