|
||
|
|
Chapter 5 Search Attributes, Filters, and Results
This chapter describes the files that control how the gateway searches for objects and describes how to add search support for a new object. The chapter contains the following sections:
- Search Configuration Files
![]()
- Changing Search Scope
![]()
- Modifying Search Attributes for Advanced Searches
![]()
- Adding Search Support for a New Object
![]()
- Modifying Default Search Filters
![]()
- Customizing Search Result Templates
![]()
The
dsgwsearchprefs.confanddsgwfilter.conffiles are the search configuration files that control the gateway's search functionality. These files are stored in the gateway's template directory (/configfor the default gateway).The
dsgwsearchprefs.conffile specifies the preferences for searching object classes defined in the gateway. Each entry contains:
- The scope of the search within the Directory Server
![]()
- The search filter to append to the search string (corresponding to the search filter entry defined in
dsgwfilter.conf)![]()
- The label of the search attribute as it is displayed in the Find drop-down list on the Search form
![]()
- The object class attribute to search on
![]()
- Match types to use in search results
![]()
Define new search preferences in
dsgwsearchprefs.confwhenever a new object class with searchable attributes is added to the gateway.
The
dsgwfilter.conffile contains an entry for each search object defined indsgwsearchprefs.conf. Each entry defines the following:
- Pattern to search for
![]()
- Delimiters for the search pattern
![]()
- LDAP filter for generating search results
![]()
- Text to use in describing search results for the pattern
![]()
- Scope of the search (not required)
![]()
The name of the search filter entry for a search object is identified in
dsgwsearchprefs.conf.
Search object entries in
dsgwsearchprefs.confdefine the search scope used in searches for the corresponding object class. The default scope for gateway search objects, subtree, specifies thebaseurland all its children.The scope of a search object can be changed by editing the corresponding line in
dsgwsearchprefs.conf. Valid search scopes are shown in Table 5-1.
Modifying Search Attributes for Advanced Searches
Each search object entry in
dsgwsearchprefs.confhas a list of attributes that can be modified for advanced searches. This section explains the following:
- Standard and Advanced Searches
![]()
- Specifying Search Attributes for Person
![]()
- Directory Express Search Support for User ID
![]()
- Adding Search Support for Additional Attributes
![]()
Standard and Advanced Searches
An advanced search differs from a standard search in that users are provided with a pull-down menu of search types. In the default gateway, the Standard Search form searches on object classes defined for the gateway. The Advanced Search form allows users to also search in specific object class attributes and to specify a matching pattern. Figure 5-1 shows the Advanced Search form with search results.
Figure 5-1 Advanced Search Form: Search Results
![]()
The figures that follow show the matching patterns that can be selected in the Advanced Search form.
Figure 5-2 shows the entry type pop-up menu on the Advanced Search form.
Figure 5-2 Advanced Search Form: Entry Type
![]()
Figure 5-3 shows the attribute pop-up menu on the Advanced Search form.
Figure 5-3 Advanced Search Form: Attribute
![]()
Figure 5-4 shows the matching filter pop-up menu on the Advanced Search form.
Figure 5-4 Advanced Search Form: Matching Filter
![]()
Specifying Search Attributes for Person
The
dsgwsearchprefs.confsyntax in the following example specifies that thecn,sn,telephoneNumber,uid, andtitleattributes will be used in a search for person entries:People
""
"Search for":
"(&(objectClass=person)"
"dsgw-people"
subtree
"full name" cn 111111 "" ""
"last name" sn 111111 "" ""
"phone number" "telephoneNumber" 111011 "" ""
"e-mail address" "mail" 111111 "" ""
"user id" "uid" 111111 "" ""
"title" title 111111 "" ""
END
"is" "(%a=%v))"
"is not" "(!(%a=%v)))"
"sounds like" "(%a~=%v))"
"starts with" "(%a=%v*))"
"ends with" "(%a=*%v))"
"contains" "(%a=*%v*))"
ENDThe first column in the example specifies how the LDAP attribute shown in the second column appears in the drop-down menu on the Advanced Search form.
The third column contains a string of six bits. Each bit position in the string maps to a match type, as shown in Table 5-2. A value of 1 indicates that the match type is valid for the associated attribute. A value of 0 indicates that the match type is not valid. In the example, the bit position for the telephone number attribute is set to 0, indicating that the Directory Server will not search for sounds like match types for phone number entries on the Advanced Search form.
Table 5-2 Bit Positions and Corresponding Search Match Types
The fourth and fifth columns in the search attributes contain empty strings required by the gateway. These should not be altered.
Directory Express Search Support for User ID
Directory Express does exact matches for user ID strings. It does not attempt to match user ID substrings.
To configure substring matching for user IDs, substring index the
uidattribute and uncomment the appropriate lines inpbconfig/dsgwfilter.confand comment out the corresponding lines.Adding Search Support for Additional Attributes
The boldfaced syntax in the following example specifies preferences for searching the
pagerTelephoneNumberattribute.People
""
"Search for":
"(&(objectClass=person)
"dsgw-people"
subtree
"full name" cn 111111 "" ""
"last name" sn 111111 "" ""
"phone number" "telephoneNumber" 111011 "" ""
"e-mail address" "mail" 111111 "" ""
"user id" "uid" 111111 "" ""
"title" title 111111 "" ""
"pager number" pagerTelephoneNumber 111011 "" ""As a result of adding this syntax to
dsgwsearchprefs.conf:
- A pager number selection will appear in the drop-down menu on the Advanced Search form.
![]()
- The gateway will search the
pagerTelephoneNumberattribute of all entries within the scope of the search.![]()
- The gateway will look for values that contain, end with, start with, or are identical to the search string entered by the user. It will not look for values that sound like the search string entered by the user.
![]()
Adding Search Support for a New Object
There are two ways to add search support for a new object:
- Update entries in
dsgwsearchprefs.confanddsgwfilter.confwith definitions of search attributes for the new object. Use this method to add search support for an object that is a child of another object.![]()
- Create new entries in
dsgwsearchprefs.confanddesgwfilter.conffor a new object class. This method requires specifying preferences for searching object class attributes and defining a filter to use in expressing search results.![]()
The boldfaced syntax in the following example shows the introduction of a new object,
examplePerson, and a new attribute,dateOfBirth, to the search preferences for thepersonobject class.People
""
"Search for":
"(&(objectClass=person)(objectClass=examplePerson)"
"dsgw-people"
subtree
"full name" cn 111111 "" ""
"last name" sn 111111 "" ""
"phone number" "telephoneNumber" 111011 "" ""
"e-mail address" "mail" 111111 "" ""
"user id" "uid" 111111 "" ""
"title" title 111111 "" ""
"birthdate" dateOfBirth 111011 " " " "As a result of adding the syntax shown in the example:
- The gateway will include
examplePersonentries in its search for persons.![]()
- A
birthdatefield will appear on the Advanced Search form.![]()
- The gateway will search the
dateofBirthattribute of all entries within the scope of the search.![]()
The syntax added to
dsgwfilter.confin the following example defines the search values for thedateOfBirthattribute:"[0-9][0-9]/[0-9][0-9]/[0-9]0-9]" " " "
(dateOfBirth=%v))" "date of birth is"
(dateOfBirth=%v*))" "date of birth starts with"Adding a new search object that is not similar to existing search objects requires:
- A new entry in
dsgwsearchprefs.conf![]()
- A new entry in the
dsgwfilter.conf![]()
- A new search results template
![]()
The syntax in the following example specifies that the search definition for
OrgRolewill search thecn,l,roleOccupant,description, andtelephoneNumberattributes:"Org-Roles"
""
"Search For:"
"(&(objectClass=organizationalRole)
"dsgw-orgrole"
not-used-by-dsgw
not-used-by-dsgw
subtree
"name" "cn" 111111 "" ""
"location" "l" 111111 "" ""
"occupant" "roleOccupant" 111111 "" ""
"description" "description" 111011 "" ""
"phone number" "telephoneNumber" 111011 "" ""
END
"is" "(%a=%v))"
"is not" "(!(%a=%v)))"
"sounds like" "(%a~=%v))"
"starts with" "(%a=%v*))"
"ends with" "(%a=*%v))"
"contains" "(%a=*%v*))"
ENDThe syntax in the above example specifies a list of filters for searching attributes in the
orgRoleobject class.This example creates a new
dsgwfilter.confentry fororgrole:dsgwfilter.conf:
dsgw-orgrole"
"=" " " "(%v))" "LDAP filter is"
"^[+]*[0-9][ 0-9-]*$" " " "(telephoneNumber=*%v))" "phone number ends with"
"^\*$" " " "(cn=*))" "name is"
".*" ". _" "(cn=%v1-))" "name is"
"(cn=*%v1-*))" "name contains"
"(cn~=%v1-))" "name sounds like"Modifying search results forms is described in Modifying Search Result Templates.
Modifying Default Search Filters
The gateway uses
dsgwflter.confto map patterns in search strings to a relevant search filter and search result description (a search pattern is a grep-style regular expression).dsgwwfilter.confcan be optimized to respond to common user data patterns.Modify existing search filters in
dsgwfilter.confto support new user data patterns, instead of creating new filters.The sections that follow explain:
Search Filters for User Data Patterns
This example shows typical search filter syntax for any search string containing the @ symbol. In this example, the gateway will respond to search strings containing the @ symbol (the pattern) by searching the
"@" " ""(mail=%v))" "email address is"
"(mail=%v*))" "email address starts with"
Standard searches use only the filters associated with the first matching pattern. Advanced searches use all filters defined for the entry.
Specifying a Search Filter for a New Object
The syntax in the following example allows users to search person entries by birthday or birth month:
[0-9][0-9]/[0-9][0-9]/[0-9]0-9](dateOfBirth=%v))date of birth is
dateOfBirth=%v*))date of birth starts withAs a result of the adding the line
dateOfBirth=%v*))date of birth starts withto thedsgw-peopleentry indsgwfilter.conf, the gateway will also filter thedateofBirthattribute for values that start with the supplied value (the filter). The gateway will return a message on the search results form indicating the number of entries where the "date of birth is" or "date of birth starts with" the user-supplied value (the description).
Customizing Search Result Templates
The following sections describe how the gateway displays search results and contains procedures for customizing the gateway search result templates:
How the Gateway Displays Search Results
When a user submits a standard search or advanced search from the gateway, the gateway constructs a search string and filter for the corresponding search object and queries the Directory Server. The Directory Server responds with matching entries in the LDAP database. The gateway uses a search result template to display the entries returned by the Directory Server.
Search results are displayed as tabular data. Headings in each result tables reflect the object attributes identified in the search result template.
For example, the heading row on the search results form for a People search displays the Name, User ID, Phone Number, E-Mail Address, and Group attributes.
Table 5-3 lists the default gateway search objects and the information displayed on the search results list. Search results templates are stored in the serverRoot/clients/dsgw/config directory and use the
list-<search object>.htmlfile naming convention.
Table 5-3 Default Search Results for Search Objects
LDAP group name, NT domain name, NT group name, and description
A new search result template is required for each new object class that is not a child of another object class.
Modifying Search Result Templates
Adding Information to Search Results
This example shows how additional information can be added to the search result by modifying the corresponding search result template.
<TR>
<TH NOWRAP>Name<TH NOWRAP>Phone Number<TH NOWRAP>E-Mail Address<TH NOWRAP>Title<TH NOWRAP>Organizational Unit
</TR><TR>
<TD NOWRAP>
<!-- DS_ATTRIBUTE "attr=dn" "syntax=dn" "label=" -->
onMouseOver="window.status='Click here to view this entry in detail'; return true">
<!-- DS_ATTRIBUTE "attr=cn" "numfields=0" "defaultvalue=name" "options=readonly" -->
</A>
<TD NOWRAP>
<!-- DS_ATTRIBUTE "attr=telephoneNumber" "syntax=tel" -->
<TD NOWRAP>
<!-- DS_ATTRIBUTE "attr=mail" "syntax=mail" -->
<TD NOWRAP>
<!-- DS_ATTRIBUTE "attr=title" --></TD>
<TD NOWRAP>
<!-- DS_ATTRIBUTE "attr=ou" "syntax=cis" --></TD>
</TR>The additional HTML table heading syntax adds the Organizational Unit label to the heading row of the table. The additional
DS_ATTRIBUTEdirective syntax adds a cell to the body row of the table indicating that the information is stored in theouattribute of the entry and the string is case insensitive.Removing Information From Search Results
To remove information from a search result, remove the tag that creates the table head cell labeling the attribute and the tag that creates the Directory Server call for the corresponding attribute value from the corresponding
list-<search object>.htmlfile.For example, to remove the NT Domain attribute from the
list-NT-People.htmlsearch results file, delete the<TH NOWRAP>NT Domaintag from table heading. The table cell containing the<!-- DS_ATTRIBUTE "attr=ntuserdomainid" "syntax=ntdomain" -->directive would also need to be removed.
© 2001 Sun Microsystems, Inc. Portions copyright 1999, 2002-2003 Netscape Communications Corporation. All rights reserved.
Read the Full Copyright and Thrid-Party Acknowledgments.
Last Updated October 31, 2003