Show Table of Contents
6.4. Using Views
Virtual directory tree views, or views, create a virtual directory hierarchy, so it is easy to navigate entries, without having to make sure those entries physically exist in any particular place. The view uses information about the entries to place them in the view hierarchy, similarly to members of a filtered role or a dynamic group. Views superimpose a DIT hierarchy over a set of entries, and to client applications, views appear as ordinary container hierarchies.
6.4.1. About Views
Views create a directory tree similar to the regular hierarchy, such as using organizational unit entries for subtrees, but views entries have an additional object class (
nsview) and a filter attribute (nsviewfilter) that set up a filter for the entries which belong in that view. Once the view container entry is added, all of the entries that match the view filter instantly populate the view. The target entries only appear to exist in the view; their true location never changes. For example, a view may be created as ou=Location Views, and a filter is set for l=Mountain View. Every entry, such as cn=Jane Smith,l=Mountain View,ou=People,dc=example,dc=com, is immediately listed under the ou=Location Views entry, but the real cn=Jane Smith entry remains in the ou=People,dc=example,dc=com subtree.

Figure 6.4. A Directory Tree with a Virtual DIT View hierarchy
Virtual DIT views behave like normal DITs in that a subtree or a one-level search can be performed with the expected results being returned.
Note
There is a sample LDIF file with example views entries,
Example-views.ldif, installed with Directory Server. This file is in the /usr/share/dirsrv/data directory on Red Hat Enterprise Linux 6 (64-bit).
The Directory Server Deployment Guide has more information on how to integrate views with the directory tree hierarchy.
6.4.2. Creating Views in the Console
- Select the Directory tab.
- In the left navigation tree, create an organizational unit suffix to hold the views. For instance, for views based on the locality (
l) attribute, name this organizational unitLocation Views. Creating sub suffixes is described in Section 2.1.1.2, “Creating a New Sub Suffix Using the Console”. - Right-click
ou=Location Views, and select New > Other.
- Select
nsviewfrom the New Object menu, and click .
- In the Property Editor window, click the button, and add the organization unit object class.

- Name the organization unit according to how to organize the views. For instance,
ou=Sunnyvale. Make theouattribute the naming attribute.
- Click the button, and add the
nsviewfilterattribute.
- Create a filter that reflects the views, such as
(l=Sunnyvale).
- Click the button in the lower right corner to change the naming attribute.
Use theouof the entry as the naming attribute instead ofdescription.
- Click to close the attributes box, and click again to save the new view entry.
The new view is immediately populated with any entries matching the search filter, and any new entries added to directory are automatically included in the view.
6.4.3. Creating Views from the Command Line
- Use the
ldapmodifyutility to bind to the server and prepare it to add the new view entry to the configuration file.ldapmodify
-a-D "cn=directory manager" -W -p 389 -h server.example.com -x - Add the new views container entry, in this example, under the
dc=example,dc=comroot suffix. This entry must have thensviewobject class and thensViewFilterattribute. ThensViewFilterattribute sets the attribute-value which identifies entries that belong in the view.dn: ou=Example View,dc=example,dc=com changetype: add objectClass: top objectClass: organizationalUnit objectClass: nsview ou: Example View nsViewFilter: l=Mountain View description: Example View
6.4.4. Improving Views Performance
As Section 6.4.1, “About Views” describes, views are derived from search results based on a given filter. Part of the filter is the attribute defined in the
nsViewFilter attribute; the rest of the filter is based on the entry hierarchy, looking for the entryid and parentid of the real entries included in the view.
(|(parentid=search_base_id)(entryid=search_base_id)
If any of the searched-for attributes —
entryid, parentid, or the attribute set in nsViewFilter — are not indexed, then the views search becomes an unindexed search because the views operation searches the entire tree for matching entries.
To improve views performance, create equality indexes for
entryid, parentid, and the attribute set in nsViewFilter.
Creating equality indexes is covered in Section 9.2, “Creating Standard Indexes”, and updating existing indexes to include new attributes is covered in Section 9.3, “Applying New Indexes to Existing Databases”.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.