Chapter 2. Introduction to Directory Services
The previous chapter gave an overview of the ISO seven-layer model, describing in some detail the lower layers. In this chapter, we will discuss a class of layer 7 -- application protocols known as directory services. NIS is an example of such a directory service.
Contents:Purpose of directory services
Brief survey of common directory services
Name service switch
Which directory service to use
2.1. Purpose of directory servicesThe purpose of a directory service is to map names of one form to names of another form. Often the names of the first form are alphanumeric strings, and the second form are numbers. Or the names of the first form are simple, whereas the names of second form are complex. In the days before computing, we used directories, but they were published on paper. The most obvious one, and perhaps the inspiration for network directory services, is the telephone book. A typical telephone book for a city in the United States consists of three directories:
The white pages of residence listings can be thought of as a "structured set of data." If this data were stored on a computer, a lexicographer would call it a database ; a "structured set of data" is the definition of database in the Concise Oxford Dictionary. Sometimes, when you are in a hurry or don't have a telephone number, you dial a special telephone number (411 or 555-1212 in the United States) to ask an operator ("directory assistance") for the telephone number of the person you want to call. This directory assistance can be thought of as directory service. You, the caller, are a customer or client of the directory service, and the particular operator, is a server of the directory service. In the world of computer networking, the human server is replaced with a directory server of databases. Since there is a server, there has to be a client. The client-side of a directory service is typically a programming library which allows other applications to look up entries in the database.
2.1.1. The hosts databaseWe've so far described a lot of theory, but a concrete example of a database in directory services should crystallize the concept.
The metaphor of a telephone directory was useful in explaining the concepts of directory service, client, and server. It turns out that the concept of names of people and their telephone numbers is also a metaphor for a similar database in computer networking. Recall from Section 1.3.2, "IP host addresses" that hosts have unique numbers or addresses, just as every telephone number in the world is unique. Just as we associate names of people with their telephone numbers, in computer networking we often want to give individual hosts a name in addition to a host address. The reasons are that it is easier to remember a name than a number, and just as people move geographically, requiring new telephone number assignments, hosts can move physically (requiring a new address assignment for the host) or conversely, the function the host was serving can move from one physical host to another (requiring a new name assignment for the host).
The hostname and address entries are stored in a hosts database that the directory server can use to respond to requests from clients. As was noted earlier, the client-side of the directory service is typically a programming library. This is the case for the hosts database. There is a subroutine, known as gethostbyname( ) that takes a string name of a host and returns the address of the host. See your system's manual page for gethostbyname for the precise calling conventions. Solaris comes with a utility called getent for looking up database entries via the command line. For example:
getent can be thought of as one of the most primitive directory service clients, but nearly every application that deals with the network will be a client that needs to access the hosts database via the directory service. A more advanced client of the hosts database is a web browser such as Netscape Navigator or Internet Explorer. Browsers will link to gethostbyname or a similar interface to find the host addresses corresponding to Universal Resource Locators (URLs, those things that start with http:// ).% getent hosts frostback 184.108.40.206 frostback
Going back to the telephone concept, sometimes we would like to know the name of the caller corresponding to a telephone number. In the United States, when you call a toll free number, the merchant receiving the call has the capability to display your phone number and can map it to your name (considering that the merchant is paying for your long distance call, some might reason that this is fair). In the computer networking world, it is sometimes useful to know the hostname of the client accessing the server. For example, suppose the server side of a web browser is a web server. Web servers often keep logs of the "hits" made to the server, for the purposes of understanding how popular a web site is, what is popular, and what hosts find it popular. The web server will always be able to find the host address of the client that made the hit. To figure out the name of the host, there is a programming interface called gethostbyaddr( ), which takes a host address, and returns the name of the host. The information can be obtained from the hosts database, via the directory service. In other words, both servers and client of different services, in this case, web services, can be clients of directory services.
Copyright © 2002 O'Reilly & Associates. All rights reserved.