﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-j2ee绿洲-文章分类-LDAP</title><link>http://www.blogjava.net/livery/category/23637.html</link><description>找到属于自己的一片天空</description><language>zh-cn</language><lastBuildDate>Fri, 29 Jun 2007 22:40:47 GMT</lastBuildDate><pubDate>Fri, 29 Jun 2007 22:40:47 GMT</pubDate><ttl>60</ttl><item><title>LDAP介绍(English)</title><link>http://www.blogjava.net/livery/articles/126711.html</link><dc:creator>心情经纬</dc:creator><author>心情经纬</author><pubDate>Thu, 28 Jun 2007 01:28:00 GMT</pubDate><guid>http://www.blogjava.net/livery/articles/126711.html</guid><wfw:comment>http://www.blogjava.net/livery/comments/126711.html</wfw:comment><comments>http://www.blogjava.net/livery/articles/126711.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/livery/comments/commentRss/126711.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/livery/services/trackbacks/126711.html</trackback:ping><description><![CDATA[<p><font face="Times New Roman, Times, serif"><font size=+0>If you work in the computing industry, the chances are good that you've heard of LDAP by now. Wondering what all the excitement is about? Want to know a little more about the underlying technology? You've come to the right place. This introduction - the first in a series of articles describing how to design, implement, and integrate an LDAP environment at your company - will familiarize you with the concepts behind LDAP while leaving the really hardcore details for later. Here, we'll touch on the following topics:</font></font>
<ul>
    <li><font face="Times New Roman, Times, serif"><font color=#800080 size=+0><a href="http://www.ldapman.org/articles/intro_to_ldap.html#what"><u>What is LDAP, anyway?</u></a></font></font>
    <li><font face="Times New Roman, Times, serif"><font color=#800080 size=+0><a href="http://www.ldapman.org/articles/intro_to_ldap.html#when"><u>When should you use LDAP to store your data?</u></a></font></font>
    <li><font face="Times New Roman, Times, serif"><font color=#800080 size=+0><a href="http://www.ldapman.org/articles/intro_to_ldap.html#structure"><u>The structure of an LDAP directory tree</u></a></font></font>
    <li><font face="Times New Roman, Times, serif"><font color=#800080 size=+0><a href="http://www.ldapman.org/articles/intro_to_ldap.html#individual"><u>Individual LDAP records</u></a></font></font>
    <li><font face="Times New Roman, Times, serif"><font color=#800080 size=+0><a href="http://www.ldapman.org/articles/intro_to_ldap.html#customizing"><u>Customizing your directory's object classes</u></a></font></font>
    <li><font face="Times New Roman, Times, serif"><font color=#800080 size=+0><a href="http://www.ldapman.org/articles/intro_to_ldap.html#example"><u>An example of an individual LDAP entry</u></a></font></font>
    <li><font face="Times New Roman, Times, serif"><font color=#800080 size=+0><a href="http://www.ldapman.org/articles/intro_to_ldap.html#replication"><u>LDAP replication</u></a></font></font>
    <li><font face="Times New Roman, Times, serif"><font color=#800080 size=+0><a href="http://www.ldapman.org/articles/intro_to_ldap.html#security"><u>Security and access control</u></a></font></font> </li>
</ul>
<!-- BEGIN --><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>To start with, what's happening with LDAP today <em>is</em> exciting. A company-wide LDAP implementation can enable almost any application, running on almost any computer platform, to obtain information from your LDAP directory. And that directory can be used to store a broad range of data: email address and mail routing information, HR data, public security keys, contact lists, and much more. By making an LDAP directory a focal point in your systems integration, you're providing one-stop shopping whenever people go looking for information within your company - even if the primary source of the data lives elsewhere.</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>But wait, you say. You're already using an Oracle, Sybase, Informix, or Microsoft SQL database to store much of that same data. How is LDAP different? What makes it better? Read on.</font></font></font>
<p><a name=what></a><font face="Times New Roman, Times, serif"><font color=#336699><font size=+2>What is LDAP, anyway?</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>The Lightweight Directory Access Protocol, better known as LDAP, is based on the X.500 standard, but significantly simpler and more readily adapted to meet custom needs. Unlike X.500, LDAP supports TCP/IP, which is necessary for Internet access. The core LDAP specifications are all defined in RFCs -- a complete list of LDAP-related RFCs may be found at the <a href="http://www.ldapman.org/ldap_rfcs.html"><u><font color=#0000ff>LDAPman RFC page</font></u></a>.</font></font></font>
<p><strong><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Using "LDAP" in a sentence</font></font></font></strong> <br><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>In everyday conversation, you'll hear well-intentioned people say things like, "Should we be storing that in LDAP?" or "Just get that data from the LDAP database," or "How do we go about tying LDAP into an RDB?" Strictly speaking, though, LDAP isn't a database at all, but a protocol used to access information stored in an information directory (also known as an LDAP directory). A more precise formulation might look something like this: "Using LDAP, data will be retrieved from (or stored in) the correct location within our information directory." But you won't find me correcting anyone on this point: either way, you get the idea across, and that's what counts.</font></font></font>
<p><strong><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Is an LDAP information directory a database?</font></font></font></strong> <br><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Just as a Database Management System (DBMS) from Sybase, Oracle, Informix, or Microsoft is used to process queries and updates to a relational database, an LDAP server is used to process queries and updates to an LDAP information directory. In other words, an LDAP information directory <em>is</em> a type of database, but it's <em>not</em> a relational database. And unlike databases that are designed for processing hundreds or thousands of changes per minute - such as the Online Transaction Processing (OLTP) systems often used in e-commerce - LDAP directories are heavily optimized for read performance.</font></font></font>
<p><strong><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>The advantages of LDAP directories</font></font></font></strong> <br><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Now that we've straightened that out, what are the advantages of LDAP directories? The current popularity of LDAP is the culmination of a number of factors. I'll give you a few basic reasons, provided you keep in mind that it's just part of the story.</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Perhaps the biggest plus for LDAP is that your company can access the LDAP directory from almost any computing platform, from any one of the increasing number of readily available, LDAP-aware applications. It's also easy to customize your company's internal applications to add LDAP support.</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>The LDAP protocol is both cross-platform and standards-based, so applications needn't worry about the type of server hosting the directory. In fact, LDAP is finding much wider industry acceptance because of its status as an Internet standard. Vendors are more willing to write LDAP integration into their products because they don't have to worry about what's at the other end. Your LDAP server could be any one of a number of open-source or commercial LDAP directory servers (or perhaps even a DBMS server with an LDAP interface), since interacting with any true LDAP server involves the same protocol, client connection package, and query commands. By contrast, vendors looking to integrate directly with a DBMS usually must tailor their product to work with each database server vendor individually.</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Unlike many relational databases, you do not have to pay for either client connection software or for licensing.</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Most LDAP servers are simple to install, easily maintained, and easily optimized.</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>LDAP servers can replicate either some or all of their data via push or pull methods, allowing you to push data to remote offices, to increase security, and so on. The replication technology is built-in and easy to configure. By contrast, many of the big DBMS vendors charge extra for this feature, and it's far more difficult to manage.</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>LDAP allows you to securely delegate read and modification authority based on your specific needs using ACIs (collectively, an ACL, or Access Control List). For example, your facilities group might be given access to change an employee's location, cube, or office number, but not be allowed to modify entries for any other fields. ACIs can control access depending on who is asking for the data, what data is being asked for, where the data is stored, and other aspects of the record being modified. This is all done through the LDAP directory directly, so you needn't worry about making security checks at the user application level.</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>LDAP is particularly useful for storing information that you wish to read from many locations, but update infrequently. For example, your company could store all of the following very efficiently in an LDAP directory:</font></font></font>
<ul>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>The company employee phone book and organizational chart</font></font></font>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>External customer contact information</font></font></font>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Infrastructure services information, including NIS maps, email aliases, and so on</font></font></font>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Configuration information for distributed software packages</font></font></font>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Public certificates and security keys</font></font></font> </li>
</ul>
<a name=when></a><font face="Times New Roman, Times, serif"><font color=#336699><font size=+2>When should you use LDAP to store your data?</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Most LDAP servers are heavily optimized for read-intensive operations. Because of this, one can typically see an order of magnitude difference when reading data from an LDAP directory versus obtaining the same data from a relational database server optimized for OLTP. Because of this optimization, however, most LDAP directories are not well suited for storing data where changes are frequent. For instance, an LDAP directory server is great for storing your company's internal telephone directory, but don't even think of using it as a database back end for your high-volume e-commerce site.</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>If the answer to each of the following questions is Yes, then storing your data in LDAP is a good idea.</font></font></font>
<ul>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Would you like your data to be available cross-platform?</font></font></font>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Do you need to access this data from a number of computers or applications?</font></font></font>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Do the individual records you're storing change a few times a day or less, on average?</font></font></font>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Does it make sense to store this type of data in a flat database instead of a relational database? That is, could you effectively store all the data for a given item in a single record?</font></font></font> </li>
</ul>
<font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>This final question often gives people pause, because it's very common to access a flat record to obtain data that's relational in nature. For example, a record for a company employee might include the login name of that employee's manager. It's fine to use LDAP to store this kind of information. Rule of thumb: If you can imagine storing your data in a large electronic Rolodex, you can store it easily in an LDAP directory.</font></font></font>
<p><a name=structure></a><font face="Times New Roman, Times, serif"><font color=#336699><font size=+2>The structure of an LDAP directory tree</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>LDAP directory servers store their data hierarchically. If you've seen the top-down representations of DNS trees or UNIX file directories, an LDAP directory structure will be familiar ground. As with DNS host names, an LDAP directory record's Distinguished Name (DN for short) is read from the individual entry, backwards through the tree, up to the top level. More on this point later.</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Why break things up into a hierarchy? There are a number of reasons. Here are a few possible scenarios:</font></font></font>
<ul>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>You may wish to push all your US-based customer contact information to an LDAP server in the Seattle office (which is devoted to sales), whereas you probably don't need to push the company's asset management information there.</font></font></font>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>You may wish to grant permissions to a group of individuals based on the directory structure. In the example listed below, the company's asset management team might need full access to the asset-mgmt section, but not to other areas.</font></font></font>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Combined with replication, you can tailor the layout of your directory structure to minimize WAN bandwidth utilization. Your sales office in Seattle might need up-to-the minute updates for US sales contacts, but only hourly updates for European sales information.</font></font></font> </li>
</ul>
<strong><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Getting to the root of the matter: Your base DN and you</font></font></font></strong> <br><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>The top level of the LDAP directory tree is the base, referred to as the "base DN." A base DN usually takes one of the three forms listed here. Let's assume I work at a US electronic commerce company called FooBar, Inc., which is on the Internet at foobar.com.</font></font></font>
<p><strong><tt><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>o="FooBar, Inc.", c=US</font></font></font></tt></strong> <br><em><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>(base DN in X.500 format)</font></font></font></em> <br><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>In this example, <tt>o=FooBar, Inc.</tt> refers to the organization, which in this context should be treated as synonymous with the company name. <tt>c=US</tt> indicates that the company headquarters is in the US. Once upon a time, this was the preferred method of specifying your base DN. Times and fashions change, though; these days, most companies are (or plan to be) on the Internet. And what with Internet globalization, using a country code in the base DN probably made things more confusing in the end. In time, the X.500 format evolved into the other formats listed below.</font></font></font>
<p><strong><tt><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>o=foobar.com</font></font></font></tt></strong> <br><em><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>(base DN derived from the company's Internet presence)</font></font></font></em> <br><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>This format is fairly straightforward, using the company's Internet domain name as the base. Once you get past the <tt>o=</tt> portion (which stands for <tt>organization=</tt>), everyone at your company should know where the rest came from. This was, until recently, probably the most common of the currently used formats.</font></font></font>
<p><strong><tt><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>dc=foobar, dc=com</font></font></font></tt></strong> <br><em><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>(base DN derived from the company's DNS domain components)</font></font></font></em> <br><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>As with the previous format, this uses the DNS domain name as its basis. But where the other format leaves the domain name intact (and thus human-readable), this format is split into domain components: <tt>foobar.com</tt> becomes <tt>dc=foobar, dc=com</tt>. In theory, this could be slightly more versatile, though it's a little harder for end users to remember. By way of illustration, consider foobar.com. When foobar.com merges with gizmo.com, you simply start thinking of "dc=com" as the base DN. Place the new records into your existing directory under dc=gizmo, dc=com, and you're ready to go. (Of course, this approach doesn't help if foobar.com merges with wocket.edu.) This is the format I'd recommend for any new installations. Oh, and if you're planning to use Active Directory, Microsoft has already decided for you that this is the format you wanted.</font></font></font>
<p><strong><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Time to branch out: How to organize your data in your directory tree</font></font></font></strong> <br><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>In a UNIX file system, the top level is the root. Beneath the root you have numerous files and directories. As mentioned above, LDAP directories are set up in much the same manner.</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Underneath your directory's base, you'll want to create containers that logically separate your data. For historical (X.500) reasons, most LDAP directories set these logical separations up as OU entries. OU stands for "Organizational Unit," which in X.500 was used to indicate the functional organization within a company: sales, finance, et cetera. Current LDAP implementations have kept the <tt>ou=</tt> naming convention, but break things apart by broad categories like <tt>ou=people</tt>, <tt>ou=groups</tt>, <tt>ou=devices</tt>, and so on. Lower level OUs are sometimes used to break categories down further. For example, an LDAP directory tree (not including individual entries) might look like this:</font></font></font>
<pre><tt><font color=#000000><font size=+0>&nbsp;&nbsp;&nbsp; dc=foobar, dc=com&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ou=customers&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ou=asia&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ou=europe&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ou=usa&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ou=employees&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ou=rooms&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ou=groups&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ou=assets-mgmt&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ou=nisgroups&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ou=recipes</font></font></tt></pre>
<a name=individual></a><font face="Times New Roman, Times, serif"><font color=#336699><font size=+2>Individual LDAP records</font></font></font>
<p><strong><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>What's in a name? The DN of an LDAP entry</font></font></font></strong> <br><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>All entries stored in an LDAP directory have a unique "Distinguished Name," or DN. The DN for each LDAP entry is composed of two parts: the Relative Distinguished Name (RDN) and the location within the LDAP directory where the record resides.</font></font></font>
<p><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>The RDN is the portion of your DN that is not related to the directory tree structure. Most items that you'll store in an LDAP directory will have a name, and the name is frequently stored in the <tt>cn</tt> (Common Name) attribute. Since nearly everything has a name, most objects you'll store in LDAP will use their <tt>cn</tt> value as the basis for their RDN. If I'm storing a record for my favorite oatmeal recipe, I'll be using <strong><tt>cn=Oatmeal Deluxe</tt></strong> as the RDN of my entry.</font></font></font>
<ul>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>My directory's base DN is <strong><tt>dc=foobar,dc=com</tt></strong></font></font></font>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>I'm storing all the LDAP records for my recipes in <strong><tt>ou=recipes</tt></strong></font></font></font>
    <li><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>The RDN of my LDAP record is <strong><tt>cn=Oatmeal Deluxe</tt></strong></font></font></font> </li>
</ul>
<font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Given all this, what's the full DN of the LDAP record for this oatmeal recipe? Remember, it reads backwards - just like a host name in DNS.</font></font></font>
<p><strong><tt><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>cn=Oatmeal Deluxe,ou=recipes,dc=foobar,dc=com</font></font></font></tt></strong>
<p><strong><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>People are always more trouble than inanimate objects</font></font></font></strong> <br><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Now it's time to tackle the DN of a company employee. For user accounts, you'll typically see a DN based either on the <tt>cn</tt> or on the <tt>uid</tt> (User ID). For example, the DN for FooBar's employee Fran Smith (login name: fsmith) might look like either of these two formats:</font></font></font>
<p><strong><tt><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>uid=fsmith,ou=employees,dc=foobar,dc=com</font></font></font></tt></strong> <br><em><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>(login-based)</font></font></font></em> <br><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>LDAP (and X.500) use <tt>uid</tt> to mean "User ID", not to be confused with the UNIX uid number. Most companies try to give everyone a unique login name, so this approach makes good sense for storing information about employees. You don't have to worry about what you'll do when you hire the next Fran Smith, and if Fran changes her name (marriage? divorce? religious experience?), you won't have to change the DN of the LDAP entry.</font></font></font>
<p><strong><tt><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>cn=Fran Smith,ou=employees,dc=foobar,dc=com</font></font></font></tt></strong> <br><em><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>(name-based)</font></font></font></em> <br><font face="Times New Roman, Times, Serif"><font color=#000000><font size=+0>Here we see the Common Name (CN) entry used. In the case of an LDAP record for a person, think of the common name as their full name. One can easily see the downside to this approach: if the name changes, the LDAP record has to "move" from one DN to another. As indicated above, you want to avoid changing the DN of an entry whenever possible.</font></font></font>
<p><a name=customizing></a><font face="Times New Roman, Times, serif"><font color=#336699><font size=+2>Customizing your directory's object classes</font></font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>You can use LDAP to store data on almost any type of object, as long as that object can be described in terms of various attributes. Here are a few examples of information you might store:</font></font>
<ul>
    <li><font face="Times New Roman, Times, serif"><font size=+0>Employees: What's the employee's full name, login name, password, employee number, manager's login, mail server?</font></font>
    <li><font face="Times New Roman, Times, serif"><font size=+0>Asset tracking: What's the computer name, IP address, asset tag, make and model information, physical location?</font></font>
    <li><font face="Times New Roman, Times, serif"><font size=+0>Customer contact lists: What's the customer's company name? The primary contact's phone, fax, and email information?</font></font>
    <li><font face="Times New Roman, Times, serif"><font size=+0>Meeting room information: What's the room name, location, seating capacity, telephone number? Is there wheelchair access? Is there an overhead projector?</font></font>
    <li><font face="Times New Roman, Times, serif"><font size=+0>Recipe information: Give the name of the dish, the list of ingredients, the type of cuisine, and instructions for preparing it.</font></font> </li>
</ul>
<font face="Times New Roman, Times, serif"><font size=+0>Because your LDAP directory can be customized to store any type of text or binary data, what you store is really up to you. LDAP directories use the concept of object classes to define which attributes are allowed for objects of any given type. In almost every LDAP implementation, you'll want to extend the basic functionality of your LDAP directory to meet your specific needs, either by creating new object classes or by extending existing ones.</font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>LDAP directories store all information for a given record's entries as a series of attribute pairs, each one consisting of an attribute type and an attribute value. (This is completely different from the way relational database servers store data, in columns and rows.) Consider this portion of my recipe record, as stored in an LDAP directory:</font></font>
<pre><tt><font size=+0>&nbsp; dn: cn=Oatmeal Deluxe, ou=recipes, dc=foobar, dc=com&nbsp;
&nbsp; cn: Instant Oatmeal Deluxe&nbsp;
&nbsp; recipeCuisine: breakfast&nbsp;
&nbsp; recipeIngredient: 1 packet instant oatmeal&nbsp;
&nbsp; recipeIngredient: 1 cup water&nbsp;
&nbsp; recipeIngredient: 1 pinch salt&nbsp;
&nbsp; recipeIngredient: 1 tsp brown sugar&nbsp;
&nbsp; recipeIngredient: 1/4 apple, any type</font></tt></pre>
<font face="Times New Roman, Times, serif"><font size=+0>Note that in this case, each ingredient is listed as a value of attribute type <tt>recipeIngredient</tt>. LDAP directories are designed to store multiple values of a single type in this fashion, rather than storing the entire list in a single database field with some sort of delimiter to distinguish the individual values.</font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>Because the data is stored in this way, the shape of the database can be completely fluid - you don't need to recreate a database table (and all its indexes) to start tracking a new piece of data. Even more important, LDAP directories use no memory or storage to handle "empty" fields - in fact, having unused optional fields costs you nothing at all.</font></font>
<p><a name=example></a><font face="Times New Roman, Times, serif"><font color=#336699><font size=+2>An example of an individual LDAP entry</font></font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>Let's look at an example. We'll use the LDAP record of Fran Smith, our friendly employee from Foobar, Inc. The format of this entry is LDIF, the format used when exporting and importing LDAP directory entries.</font></font>
<pre><tt><font size=+0>&nbsp; dn: uid=fsmith, ou=employees, dc=foobar, dc=com
&nbsp; objectclass: person
&nbsp; objectclass: organizationalPerson
&nbsp; objectclass: inetOrgPerson
&nbsp; objectclass: foobarPerson
&nbsp; uid: fsmith
&nbsp; givenname: Fran
&nbsp; sn: Smith
&nbsp; cn: Fran Smith
&nbsp; cn: Frances Smith
&nbsp; telephonenumber: 510-555-1234
&nbsp; roomnumber: 122G
&nbsp; o: Foobar, Inc.
&nbsp; mailRoutingAddress: fsmith@foobar.com
&nbsp; mailhost: mail.foobar.com
&nbsp; userpassword: {crypt}3x1231v76T89N
&nbsp; uidnumber: 1234
&nbsp; gidnumber: 1200
&nbsp; homedirectory: /home/fsmith
&nbsp; loginshell: /usr/local/bin/bash</font></tt></pre>
<font face="Times New Roman, Times, serif"><font size=+0>To start with, attribute values are stored with case intact, but searches against them are case-insensitive by default. Certain attributes (like password) are case-sensitive when searching.</font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>Let's break this entry down and look at it piece by piece.</font></font>
<pre><font face="Times New Roman, Times, serif"><font size=+0>&nbsp; dn: uid=fsmith, ou=employees, dc=foobar, dc=com</font></font></pre>
<font face="Times New Roman, Times, serif"><font size=+0>This is the full DN of Fran's LDAP entry, including the whole path to the entry in the directory tree. LDAP (and X.500) use <tt>uid</tt> to mean "User ID," not to be confused with the UNIX uid number.</font></font>
<pre><tt><font size=+0>&nbsp; objectclass: person&nbsp;
&nbsp; objectclass: organizationalPerson&nbsp;
&nbsp; objectclass: inetOrgPerson&nbsp;
&nbsp; objectclass: foobarPerson</font></tt></pre>
<font face="Times New Roman, Times, serif"><font size=+0>One can assign as many object classes as are applicable to any given type of object. The <tt>person</tt> object class requires that the <tt>cn</tt> (common name) and <tt>sn</tt> (surname) fields have values. Object Class <tt>person</tt> also allows other optional fields, including givenname, telephonenumber, and so on. The object class <tt>organizationalPerson</tt> adds more options to the values from <tt>person</tt>, and <tt>inetOrgPerson</tt> adds still more options to that (including email information). Finally, <tt>foobarPerson</tt> is Foobar's customized object class that adds all the custom attributes they wish to track at their company.</font></font>
<pre><font size=+0><font face="Times New Roman, Times, serif">&nbsp;</font><tt> uid: fsmith&nbsp;
&nbsp; givenname: Fran&nbsp;
&nbsp; sn: Smith&nbsp;
&nbsp; cn: Fran Smith&nbsp;
&nbsp; cn: Frances Smith&nbsp;
&nbsp; telephonenumber: 510-555-1234&nbsp;
&nbsp; roomnumber: 122G&nbsp;
&nbsp; o: Foobar, Inc.</tt></font></pre>
<font face="Times New Roman, Times, serif"><font size=+0>As mentioned before, <tt>uid</tt> stands for User ID. Just translate it in your head to "login" whenever you see it.</font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>Note that there are multiple entries for the CN. As mentioned above, LDAP allows some attributes to have multiple values, with the number of values being arbitrary. When would you want this? Let's say you're searching the company LDAP directory for Fran's phone number. While <em>you</em> might know her as Fran (having heard her spill her guts over lunchtime margaritas on more than one occasion), the people in HR may refer to her (somewhat more formally) as Frances. Because both versions of her name are stored, either search will successfully look up Fran's telephone number, email, cube number, and so on.</font></font>
<pre><font face="Times New Roman, Times, serif"><font size=+0>&nbsp; mailRoutingAddress: fsmith@foobar.com&nbsp;
&nbsp; mailhost: mail.foobar.com</font></font></pre>
<font face="Times New Roman, Times, serif"><font size=+0>Like most companies on the Internet, Foobar uses Sendmail for internal mail delivery and routing. Foobar stores all users' mail routing information in LDAP, which is fully supported by recent versions of Sendmail.</font></font>
<pre><font size=+0><font face="Times New Roman, Times, serif">&nbsp; </font><tt>userpassword: {crypt}3x1231v76T89N&nbsp;
&nbsp; uidnumber: 1234&nbsp;
&nbsp; gidnumber: 1200&nbsp;
&nbsp; gecos: Frances Smith&nbsp;
&nbsp; homedirectory: /home/fsmith&nbsp;
&nbsp; loginshell: /usr/local/bin/bash</tt></font></pre>
<font face="Times New Roman, Times, serif"><font size=+0>Note that Foobar's systems administrators store all the NIS password map information in LDAP as well. At Foobar, the <tt>foobarPerson</tt> object class adds this capability. Note that the user password is stored in UNIX crypt format. The UNIX uid is stored here as <tt>uidnumber</tt>. Mind you, there's a whole RFC on storing NIS information in LDAP. I'll talk about NIS integration in a future article.</font></font>
<p><a name=replication></a><font face="Times New Roman, Times, serif"><font color=#336699><font size=+2>LDAP replication</font></font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>LDAP servers can be set to replicate some or all of their data, on a push or a pull basis, using simple authentication or certificate-based authentication.</font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>For example, Foobar has a "public" LDAP server running on ldap.foobar.com, port 389. This server is used by Netscape Communicator's pinpoint email addressing feature, the "ph" command from UNIX, and other locations where a user would want to query for the phone number of an employee or customer contact. The company's master LDAP server is running on the same system, but on port 1389 instead.</font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>You wouldn't necessarily want employees searching the directory to query against asset management or recipe data, nor would it be desirable to see IT accounts (like "root") showing up on the company directory. To accomodate these unpleasant realities, Foobar replicates selected directory subtrees from its master LDAP server to its "public" server. The replication excludes subtrees containing data they wish to hide. To keep things current at all times, the master directory server is set to do immediate push-based synchronization. Note that this approach is designed for convenience, not security: the idea is to allow power users to simply query the other LDAP port if they want to search all available data.</font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>Let's say Foobar is managing its customer contact information via LDAP, over a low bandwidth connection between Oakland and Europe. They might set up replication from ldap.foobar.com:1389 to munich-ldap.foobar.com:389 as follows:</font></font>
<pre><font size=+0><font face="Times New Roman, Times, serif">&nbsp; <em>periodic pull: </em></font><tt>ou=asia,ou=customers,o=sendmail.com
</tt><font face="Times New Roman, Times, serif">&nbsp; <em>periodic pull:</em></font><tt> ou=us,ou=customers,o=sendmail.com
</tt><font face="Times New Roman, Times, serif">&nbsp; <em>immediate push:</em></font><tt> ou=europe,ou=customers,o=sendmail.com</tt></font></pre>
<font face="Times New Roman, Times, serif"><font size=+0>The pull connections would keep things in sync every 15 minutes, which would probably be just fine in this scenario. The push connection would guarantee that any change made to the European contact information would be pushed out to Munich immediately.</font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>Given this replication scheme, where would users connect to access their data? Users in Munich could simply connect to their local server. If they were making changes to the data, the local LDAP server would refer those changes to the master LDAP server, which would then push all the changes back to the local LDAP server to keep it in sync. This is of tremendous benefit to the local user: all their LDAP queries (mostly reads) are against their local server, which is substantially faster. When it's time to make a change to their information, end users needn't worry about reconfiguring their client software, because the LDAP directory servers handle the data exchange for them.</font></font>
<p><a name=security></a><font face="Times New Roman, Times, serif"><font color=#336699><font size=+2>Security and access control</font></font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>LDAP provides for a complex level of access control instances, or ACIs. Because the access can be controlled on the server side, it's much more secure than security methods that work by securing data through client software.</font></font>
<p><font face="Times New Roman, Times, serif"><font size=+0>With LDAP ACIs, you can do things like:</font></font>
<ul>
    <li><font face="Times New Roman, Times, serif"><font size=+0>Grant users the ability to change their home phone number and home address, while restricting them to read-only access for other data types (such as job title or manager's login).</font></font>
    <li><font face="Times New Roman, Times, serif"><font size=+0>Grant anyone in the group "HR-admins" the ability to modify any user's information for the following fields: manager, job title, employee ID number, department name, and department number. There would be no write permission to other fields.</font></font>
    <li><font face="Times New Roman, Times, serif"><font size=+0>Deny read access to anyone attempting to query LDAP for a user's password, while still allowing a user to change his or her own password.</font></font>
    <li><font face="Times New Roman, Times, serif"><font size=+0>Grant managers read-only permission for the home phone numbers of their direct reports, while denying this privilege to anyone else.</font></font>
    <li><font face="Times New Roman, Times, serif"><font size=+0>Grant anyone in the group "host-admins" to create, delete, and edit all aspects of host information stored in LDAP.</font></font>
    <li><font face="Times New Roman, Times, serif"><font size=+0>Via a Web page, allow people in "foobar-sales" to selectively grant or deny themselves read access to subsets of the customer contact database. This would, in turn, allow these individuals to download the customer contact information to their local laptops or to a PDA. (This will be most useful if your sales force automation tool is LDAP-aware.)</font></font>
    <li><font face="Times New Roman, Times, serif"><font size=+0>Via a Web page, allow any group owner to add or remove any entries from groups they own. For example, this would allow sales managers to grant or remove access for salespeople to modify Web pages. This would allow owners of mail aliases to add and remove users without having to contact IT. Mailing lists designated as "public" could allow users to add or remove themselves (but only themselves) to or from those mail aliases. Restrictions can also be based on IP address or hostname. For example, fields can be made readable only if the user's IP address begins with 192.168.200.*, or if the user's reverse DNS hostname maps to *.foobar.com.</font></font> </li>
</ul>
<font face="Times New Roman, Times, serif"><font size=+0>This will give you an idea what's possible using access control with LDAP directories, but be aware that a correct implementation requires much more information than is given here. I'll discuss access control in greater detail in a future article.</font></font> 
<img src ="http://www.blogjava.net/livery/aggbug/126711.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/livery/" target="_blank">心情经纬</a> 2007-06-28 09:28 <a href="http://www.blogjava.net/livery/articles/126711.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>LDAP初探(1)</title><link>http://www.blogjava.net/livery/articles/126709.html</link><dc:creator>心情经纬</dc:creator><author>心情经纬</author><pubDate>Thu, 28 Jun 2007 01:26:00 GMT</pubDate><guid>http://www.blogjava.net/livery/articles/126709.html</guid><wfw:comment>http://www.blogjava.net/livery/comments/126709.html</wfw:comment><comments>http://www.blogjava.net/livery/articles/126709.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/livery/comments/commentRss/126709.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/livery/services/trackbacks/126709.html</trackback:ping><description><![CDATA[<p>1.1.&nbsp;LDAP是什么<br>LDAP是轻量目录访问协议，英文全称是Lightweight Directory Access Protocol，一般都简称为LDAP。它是基于X.500标准的，但是简单多了并且可以根据需要定制。与X.500不同，LDAP支持TCP/IP，这对访问Internet是必须的。LDAP的核心规范在RFC中都有定义，所有与LDAP相关的RFC都可以在LDAPman RFC网页中找到。<br>简单说来，LDAP是一个得到关于人或者资源的集中、静态数据的快速方式。 <br>LDAP是一个用来发布目录信息到许多不同资源的协议。通常它都作为一个集中的地址本使用，不过根据组织者的需要，它可以做得更加强大。 <br>1.2.&nbsp;LDAP是电话簿<br>LDAP其实是一电话簿，类似于我们所使用诸如NIS(Network Information Service)、DNS (Domain Name Service)等网络目录，也类似于你在花园中所看到的树木。 <br>1.3.&nbsp;LDAP是不是数据库<br>不少LDAP开发人员喜欢把LDAP与关系数据库相比，认为是另一种的存贮方式，然后在读性能上进行比较。实际上，这种对比的基础是错误的。LDAP和关系数据库是两种不同层次的概念，后者是存贮方式（同一层次如网格数据库，对象数据库），前者是存贮模式和访问协议。LDAP是一个比关系数据库抽象层次更高的存贮概念，与关系数据库的查询语言SQL属同一级别。LDAP最基本的形式是一个连接数据库的标准方式。该数据库为读查询作了优化。因此它可以很快地得到查询结果，不过在其它方面，例如更新，就慢得多。<br>从另一个意义上 LDAP是实现了指定的数据结构的存贮，它是一种特殊的数据库。但是LDAP和一般的数据库不同，明白这一点是很重要的。 LDAP对查询进行了优化，与写性能相比LDAP的读性能要优秀很多。<br>就象Sybase、Oracle、Informix或Microsoft的数据库管理系统（DBMS）是用于处理查询和更新关系型数据库那样，LDAP服务器也是用来处理查询和更新LDAP目录的。换句话来说LDAP目录也是一种类型的数据库，但不是关系型数据库。要特别注意的是，LDAP通常作为一个hierarchal数据库使用，而不是一个关系数据库。因此，它的结构用树来表示比用表格好。正因为这样，就不能用SQL语句了。 <br>2.&nbsp;LDAP的特点<br>2.1.&nbsp;LDAP的优势<br>2.1.1&nbsp;跨平台<br>LDAP最大的优势是：可以在任何计算机平台上，用很容易获得的而且数目不断增加的LDAP的客户端程序访问LDAP目录。而且也很容易定制应用程序为它加上LDAP的支持。<br>LDAP协议是跨平台的和标准的协议，因此应用程序就不用为LDAP目录放在什么样的服务器上操心了。实际上，LDAP得到了业界的广泛认可，因为它是Internet的标准。产商都很愿意在产品中加入对LDAP的支持，因为他们根本不用考虑另一端（客户端或服务端）是怎么样的。LDAP服务器可以是任何一个开发源代码或商用的LDAP目录服务器（或者还可能是具有LDAP界面的关系型数据库），因为可以用同样的协议、客户端连接软件包和查询命令与LDAP服务器进行交互。与LDAP不同的是，如果软件产商想在软件产品中集成对DBMS的支持，那么通常都要对每一个数据库服务器单独定制。<br>2.1.2&nbsp;费用及维护<br>不象很多商用的关系型数据库，你不必为LDAP的每一个客户端连接或许可协议付费。<br>大多数的LDAP服务器安装起来很简单，也容易维护和优化。<br>2.1.3&nbsp;复制技术<br>LDAP服务器可以用"推"或"拉"的方法复制部分或全部数据，例如：可以把数据"推"到远程的办公室，以增加数据的安全性。复制技术是内置在LDAP服务器中的而且很容易配置。如果要在DBMS中使用相同的复制功能，数据库产商就会要你支付额外的费用，而且也很难管理。<br>2.1.4&nbsp;允许使用ACI<br>LDAP允许你根据需要使用ACI（一般都称为ACL或者访问控制列表）控制对数据读和写的权限。例如，设备管理员可以有权改变员工的工作地点和办公室号码，但是不允许改变记录中其它的域。ACI可以根据谁访问数据、访问什么数据、数据存在什么地方以及其它对数据进行访问控制。因为这些都是由LDAP目录服务器完成的，所以不用担心在客户端的应用程序上是否要进行安全检查。<br>2.2.&nbsp;LDAP存储什么数据<br>LDAP对于这样存储这样的信息最为有用：也就是数据需要从不同的地点读取，但是不需要经常更新。例如，这些信息存储在LDAP目录中是十分有效的：<br>l&nbsp;公司员工的电话号码簿和组织结构图<br>l&nbsp;客户的联系信息<br>l&nbsp;计算机管理需要的信息，包括NIS映射、email假名，等等<br>l&nbsp;软件包的配置信息<br>l&nbsp;公用证书和安全密匙<br>2.3.&nbsp;什么时候该用LDAP存储数据<br>大多数的LDAP服务器都为读密集型的操作进行专门的优化。因此，当从LDAP服务器中读取数据的时候会比从专门为OLTP优化的关系型数据库中读取数据快一个数量级。也是因为专门为读的性能进行优化，大多数的LDAP目录服务器并不适合存储需要需要经常改变的数据。例如，用LDAP服务器来存储电话号码是一个很好的选择，但是它不能作为电子商务站点的数据库服务器。<br>如果下面每一个问题的答案都是"是"，那么把数据存在LDAP中就是一个好主意。<br>l&nbsp;需要在任何平台上都能读取数据吗？<br>l&nbsp;每一个单独的记录项是不是每一天都只有很少的改变？<br>l&nbsp;可以把数据存在平面数据库（flat database）而不是关系型数据库中吗？换句话来说，也就是不管什么范式不范式的，把所有东西都存在一个记录中（差不多只要满足第一范式）。<br>最后一个问题可能会唬住一些人，其实用平面数据库去存储一些关系型的数据也是很一般的。例如，一条公司员工的记录就可以包含经理的登录名。用LDAP来存储这类信息是很方便的。一个简单的判断方法：如果可以把保数据存在一张张的卡片里，就可以很容易地把它存在LDAP目录里。<br>3.&nbsp;LDAP的基本模型 <br>3.1&nbsp;信息模型：描述LDAP的信息表示方式 <br>在LDAP中信息以树状方式组织，在树状信息中的基本数据单元是条目，而每个条目由属性构成，属性中存储有属性值；LDAP中的信息模式，类似于面向对象的概念，在LDAP中每个条目必须属于某个或多个对象类（Object Class），每个Object Class由多个属性类型组成，每个属性类型有所对应的语法和匹配规则；对象类和属性类型的定义均可以使用继承的概念。每个条目创建时，必须定义所属的对象类，必须提供对象类中的必选属性类型的属性值，在LDAP中一个属性类型可以对应多个值。 <br>在LDAP中把对象类、属性类型、语法和匹配规则统称为Schema，在LDAP中有许多系统对象类、属性类型、语法和匹配规则，这些系统Schema在LDAP标准中进行了规定，同时不同的应用领域也定义了自己的Schema，同时用户在应用时，也可以根据需要自定义Schema。这有些类似于XML，除了XML标准中的XML定义外，每个行业都有自己标准的DTD或DOM定义，用户也可以自扩展；也如同XML，在LDAP中也鼓励用户尽量使用标准的Schema，以增强信息的互联互通。 <br>在Schema中最难理解的是匹配规则，这是LDAP中为了加快查询的速度，针对不同的数据类型，可以提供不同的匹配方法，如针对字符串类型的相等、模糊、大于小于均提供自己的匹配规则。 <br>3.2&nbsp;命名模型：描述LDAP中的数据如何组织 <br>LDAP中的命名模型，也即LDAP中的条目定位方式。在LDAP中每个条目均有自己的DN和RDN。DN是该条目在整个树中的唯一名称标识，RDN是条目在父节点下的唯一名称标识，如同文件系统中，带路径的文件名就是DN，文件名就是RDN。 <br>3.3&nbsp;功能模型：描述LDAP中的数据操作访问 <br>在LDAP中共有四类10种操作：查询类操作，如搜索、比较；更新类操作，如添加条目、删除条目、修改条目、修改条目名；认证类操作，如绑定、解绑定；其它操作，如放弃和扩展操作。除了扩展操作，另外9种是LDAP的标准操作；扩展操作是LDAP中为了增加新的功能，提供的一种标准的扩展框架，当前已经成为LDAP标准的扩展操作，有修改密码和StartTLS扩展，在新的RFC标准和草案中正在增加一些新的扩展操作，不同的LDAP厂商也均定义了自己的扩展操作。 <br>3.4&nbsp;安全模型：描述LDAP中的安全机制 <br>LDAP中的安全模型主要通过身份认证、安全通道和访问控制来实现。 <br>3.4.1&nbsp;身份认证<br>在LDAP中提供三种认证机制，即匿名、基本认证和SASL（Simple Authentication and Secure Layer）认证。匿名认证即不对用户进行认证，该方法仅对完全公开的方式适用；基本认证均是通过用户名和密码进行身份识别，又分为简单密码和摘要密码认证；SASL认证即LDAP提供的在SSL和TLS安全通道基础上进行的身份认证，包括数字证书的认证。 <br>3.4.2&nbsp;通讯安全<br>在LDAP中提供了基于SSL/TLS的通讯安全保障。SSL/TLS是基于PKI信息安全技术，是目前Internet上广泛采用的安全服务。LDAP通过StartTLS方式启动TLS服务，可以提供通讯中的数据保密性、完整性保护；通过强制客户端证书认证的TLS服务，同时可以实现对客户端身份和服务器端身份的双向验证。 <br>3.4.3&nbsp;访问控制<br>虽然LDAP目前并无访问控制的标准，但从一些草案中或是事实上LDAP产品的访问控制情况，我们不难看出：LDAP访问控制异常的灵活和丰富，在LDAP中是基于访问控制策略语句来实现访问控制的，这不同于现有的关系型数据库系统和应用系统，它是通过基于访问控制列表来实现的，无论是基于组模式或角色模式，都摆脱不了这种限制。 <br>在使用关系型数据库系统开发应用时，往往是通过几个固定的数据库用户名访问数据库。对于应用系统本身的访问控制，通常是需要建立专门的用户表，在应用系统内开发针对不同用户的访问控制授权代码，这样一旦访问控制策略变更时，往往需要代码进行变更。总之一句话，关系型数据库的应用中用户数据管理和数据库访问标识是分离的，复杂的数据访问控制需要通过应用来实现。 <br>而对于LDAP，用户数据管理和访问标识是一体的，应用不需要关心访问控制的实现。这是由于在LDAP中的访问控制语句是基于策略语句来实现的，无论是访问控制的数据对象，还是访问控制的主体对象，均是与这些对象在树中的位置和对象本身的数据特征相关。 <br>在LDAP中，可以把整个目录、目录的子树、制定条目、特定条目属性集或符合某过滤条件的条目作为控制对象进行授权；可以把特定用户、属于特定组或所有目录用户作为授权主体进行授权；最后，还可以定义对特定位置（例如IP地址或DNS名称）的访问权。 </p>
<br>
<p>4.&nbsp;LDAP数据结构<br>LDAP是实现了指定的数据结构的存贮，它包括以下可以用关系数据库实现的结构要求：树状组织、条目认证、类型定义、许可树形记录拷贝。<br>4.1&nbsp;树状组织<br>无论是X500还是LDAP都是采用树状方式进行记录。每一个树目录都有一个树根的入口条目，子记录全部是这一根条目的子孙。这是目录与关系数据类型最大的区别（关系数据库的应用结构也可实现树状记录）。因此，把目录看作是更高级的树状数据库也未尝不可，只不过除此外，它不能实现关系存贮的重要功能。<br>4.2&nbsp;条目和条目认证<br>LDAP是以条目作为认证的根据。ROOT的权限认证与目录本身无关，但除此外所有条目的认证权限由条目本身的密码进行认证。LDAP可以配置成各种各样不同的父子条目权限继承方式。<br>每一个条目相当于一个单一的平面文本记录，由条目自身或指定的条目认证进行访问控制。因此，LDAP定义的存贮结构等同于一批树状组织的平面数据库，并提供相应的访问控制。<br>条目中的记录以名-值对的形式存在，每一个名值对必须由数据样式schema预定义。因此，LDAP可以看作是以规定的值类型以名值对形式存贮在一系列以树状组织的平面数据库的记录的集合。<br>4.3&nbsp;数据样式（schema）<br>数据样式schema是针对不同的应用，由用户指定（设计）类和属性类型预定义，条目中的类(objectclass)和属性必须在在LDAP服务器启动时载入内存的schema已有定义。因此，AD活动目录中的条目记录就必须符合Active Directory的schema中。如果已提供的schema中的定义不够用，用户可以自行定义新的schema.<br>在<a href="http://ldap.akbkhome.com/index.php"><font color=#007799><u>http://ldap.akbkhome.com/index.php</u></font></a>中可以看到常用的schema。<br>4.4&nbsp;对象类型(objectClass)<br>因为LDAP目录可以定制成存储任何文本或二进制数据，到底存什么要由你自己决定。LDAP目录用对象类型（objectclass）的概念来定义运行哪一类的对象使用什么属性。在几乎所有的LDAP服务器中，你都要根据自己的需要扩展基本的LDAP目录的功能，创建新的对象类型或者扩展现存的对象类型。<br>条目中的记录通过objectclass实现分类，objectClass是一个继承性的类定义，每一个类定义指定必须具备的属性。如某一条目指定必须符合某个类型，则它必须具备超类所指定的属性。<br>通过objectclass分类，分散的条目中的记录就实际上建立了一个索引结构，为高速的读查询打下了基础。Objectclass也是过滤器的主要查询对象。<br>4.5&nbsp;过滤器和语法<br>LDAP是一个查询为主的记录结构，无论是何种查询方式，最终都由过滤器缺点查询的条件。过滤器相当于SQL中的WHERE子句。任何LDAP的类过滤和字符串都必须放在括号内，如（objectclass=*）,指列出所有类型的记录（不过分类）。<br></p>
<img src ="http://www.blogjava.net/livery/aggbug/126709.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/livery/" target="_blank">心情经纬</a> 2007-06-28 09:26 <a href="http://www.blogjava.net/livery/articles/126709.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>