exclude a user from people directory
Asked by Alicia Miller:

Hi all,

Does anyone know how to exclude a user from the "people directory".

It would be useful to not display "admin" for example.

Thanks,

Alicia


Answers:
author: Davin Studer
body: There is no easy way to do it. There aren't any options you can set to exclude them ... lame as it is. I had to hijack the search page to do this.

What I did for this is I created some JavaScript that I included in the "At the end of BODY" section in the custom HTML. This script will run on each page at this point since it is included on every page. So, I do a check in the script first thing to see if I am on the people directory page. If so, then I hide the default search form and create my own that has the inputs I want with a submit button. When the submit button is clicked it generates the search string that will give me the people I want to look up, but I also exclude in the search string the people I don't want to show. The I populate the default search field that is hidden with the generated string and programatically click the default, now hidden, button.

I also change the "People" link in the top header bar to have a default search that removes the unwanted account(s). Some thing like this ...

```
http://{server}/dopeopledirectorysearch.action?queryString=%5Ba+TO+zzzz%5D+NOT+admin&amp;search=Search&amp;showOnlyPersonal=false&amp;startIndex=0
```

What this is doing is returning every one from A to ZZZZ (which should be everyone) except anything with admin in it. The reason for this is when you click the people link it will show you everyone at first ... including the people you don't want to see. So, to avoid these people showing I just start the people search process with a default search string that removes them.

comments: author: Alicia Miller
body: Thanks for your answer! I have instead opted to rename my admin account to something more relevant to users (ie. Service Desk). This also makes sure it is not the first user in the people directory so it is less conspicuous. Thank you for your help though.


author: Justin Justin
body: Hi Alicia,

If you are using LDAP or AD, you can exclude users or groups of users with an LDAP query string filter

Its a little tricky, but this doc describes it pretty well. <https://confluence.atlassian.com/display/CROWD/Restricting+LDAP+Scope+for+User+and+Group+Search>

These "Crowd" fields are found in Confluence when configuring your LDAP User Directory (Admin \> Users \& Security \> User Directories). Among other, you have to specify the LDAP schema and then your user object filter (or group object filter) like described in above link. This is especially useful if you have ex-employee or service accounts and you want to remove them from counting against your Confluence license (and also will fall out of the People Directory).

Hope that helps maybe down the line as you go.

Justin

comments: author: Davin Studer
body: This does remove them from the directory,but also removes them from the system. I think the question was about having someone who can log in, but does not show in the people directory ... such as a service account.


author: Justin Justin
body: I do not consider admin a "service account". A "service account" is an account often found in ADs/LDAPs to perform a service without a human. An "admin" account I think always has a user associated with it. However, point taken. An admin with that name shown in the People DIrectory does not make sense, and yes, filters removes from system. So all depends on what they are after in the People Directory.


author: Thomas Alfred
body: You could write a custom plugin to extract certain users information from the Lucene search index. This would remove them out of the directory.

Perhaps add the users to a particular group, then remove group members.This is similar to a "Do Not Index" plugin I wrote recently which removes pages based on their label


author: Jasper Knops
body: You can alter the template of the people directory which is located at: confluence/confluence/users/peopledirectory-results.vm

Just wrap an if-statement around the code that outputs the profile macro to check the username or which group the user belongs to.

In this case I hide all users inside the group confluence-administrators:

**#if (!$userAccessor.hasMembership('confluence-administrators', $person))**   
$helper.renderConfluenceMacro("{profile:user=%s\|mode=people-directory}", $person)  
**#end**

comments: author: Davin Studer
body: The one downside of this approach is that programatically those users are not actually removed from the results ... they are just skipped over when displaying. So, your results page(s) could have less than 50 results displayed.


author: rambo blood
body: that one does not work for me....

![Screenshot from 2018-07-20 10-44-49.png](https://community.atlassian.com/t5/image/serverpage/image-id/27426i2B5CCC9F3A3C2E8F/image-size/large?v=v2&px=999 "Screenshot from 2018-07-20 10-44-49.png")

I've added such code, but **confluence-administrators**members still are displayed at People directory

is there any other working solution ?


Tags: confluence-administration