ChinaUnix.net
 >> ChinaUnix.net > Solaris

Understanding LDAP

作者:hutao     发表时间:2002/12/23 12:35pm

This chapter explains the LDAP protocol and the concepts behind LDAP.

LDAP (Lightweight Directory Access Protocol) is the Internet directory protocol. Developed at the University of Michigan at Ann Arbor in conjunction with the Internet Engineering Task Force, LDAP is a protocol for accessing and managing directory services.

The chapter is organized in the following sections:


"How Directory Services Work"

"How LDAP Servers Organize Directories"

"How LDAP Clients and Servers Work"

"Understanding the LDAP v3 Protocol"

"For More Information"
If you are already familiar with LDAP, you can skip ahead to Chapter 2, "Using the Netscape Directory SDK for Java."


How Directory Services Work
A directory consists of entries containing descriptive information. For example, a directory might contain entries describing people or network resources, such as printers or fax machines.

The descriptive information is stored in the attributes of the entry. Each attribute describes a specific type of information. For example, attributes describing a person might include the person's name (common name, or cn), telephone number, and email address.

The entry for Barbara Jensen might have the following attributes:

cn: Barbara Jensen
mail: babs@ace.com
telephoneNumber: 555-1212
roomNumber: 3995

An attribute can have more than one value. For example, a person might have two common names (a formal name and a nickname) or two telephone numbers:

cn: Jennifer Jensen
cn: Jenny Jensen
mail: jen@ace.com
telephoneNumber: 555-1213
telephoneNumber: 555-2059
roomNumber: 3996

Attributes can also contain binary data. For example, attributes of a person might include the JPEG photo of the person or the voice of the person recorded in an audio file format.

A directory service is a distributed database application designed to manage the entries and attributes in a directory. A directory service also makes the entries and attributes available to users and other applications. The Netscape Directory Server is an example of a directory service.

For example, a user might use the directory service to look up someone's telephone number. Another application might use the directory service to retrieve a list of email addresses.

LDAP is a protocol defining a directory service and access to that service. LDAP is based on a client-server model. LDAP servers provide the directory service, and LDAP clients use the directory service to access entries and attributes.

An example of an LDAP server is the Netscape Directory Server, which manages and provides information about users and organizational structures of users, such as groups and departments. Examples of LDAP clients might include the HTTP gateway to the Netscape Directory Server, Netscape Navigator, and Netscape Communicator. The gateway uses the directory service to find, update, and add information about users.


How LDAP Servers Organize Directories
Because LDAP is intended to be a global directory service, data is organized hierarchically, starting at a root and branching down into individual entries.

At the top level of the hierarchy, entries represent larger organizations. Under these larger organizations in the hierarchy might be entries for smaller organizations. The hierarchy might end with entries for individual people or resources.

Figure 1.1 illustrates an example of a hierarchy of entries in an LDAP directory service.

Figure 1.1    A hierarchy of entries in the directory

Each entry is uniquely identified by a distinguished name. A distinguished name consists of a name that uniquely identifies the entry at that hierarchical level (for example, bjensen and kjensen are different user IDs that identify different entries at the same level) and a path of names that trace the entry back to the root of the tree.

For example, this might be the distinguished name for the bjensen entry:

uid=bjensen, ou=People, o=Airius.com

Here, uid represents the user ID of the entry, ou represents the organizational unit in which the entry belongs, and o represents the larger organization in which the entry belongs.

The following diagram shows how distinguished names are used to identify entries uniquely in the directory hierarchy.

Figure 1.2    An example of a distinguished name in the directory

The data stored in a directory can be distributed among several LDAP servers. For example, one LDAP server at Airius.com might contain entries representing North American organizational units and employees, while another LDAP server might contain entries representing European organizational units and employees.

Some LDAP servers are set up to refer requests to other LDAP servers. For example, if the LDAP server at Airius.com receives a request for information about an employee in a Pacific Rim branch, that server can refer the request to the LDAP server at the Pacific Rim branch. In this way, LDAP servers can appear to be a single source of directory information. Even if an LDAP server does not contain the information you request, the server can refer you to another server that does contain the information.


How LDAP Clients and Servers Work
In the LDAP client-server model, LDAP servers (such as the Netscape Directory Server) make information about people, organizations, and resources accessible to LDAP clients. The LDAP protocol defines operations that clients use to search and update the directory. An LDAP client can perform these operations, among others:


searching for and retrieving entries from the directory

adding new entries to the directory

updating entries in the directory

deleting entries from the directory

renaming entries in the directory
For example, to update an entry in the directory, an LDAP client submits the distinguished name of the entry with updated attribute information to the LDAP server. The LDAP server uses the distinguished name to find the entry and performs a modify operation to update the entry in the directory.

To perform any of these LDAP operations, an LDAP client needs to establish a connection with an LDAP server. The LDAP protocol specifies the use of TCP/IP port number 389, although servers may run on other ports.

The LDAP protocol also defines a simple method for authentication. LDAP servers can be set up to restrict permissions to the directory. Before an LDAP client can perform an operation on an LDAP server, the client must authenticate itself to the server by supplying a distinguished name and password. If the user identified by the distinguished name does not have permission to perform the operation, the server does not execute the operation.


Understanding the LDAP v3 Protocol
Many LDAP servers support version 2 of the LDAP protocol. This version of the protocol is specified in RFC 1777 (you can find a copy of this RFC at http://www.ietf.org/rfc/rfc1777.txt).

The most recent proposed standard is version 3 of the LDAP protocol, which is specified in RFC 2251 (you can find a copy of this RFC at http://www.ietf.org/rfc/rfc2251.txt). Some LDAP servers, such as the Netscape Directory Server 3.0 and later, support this newer version of the protocol.

The Netscape Directory SDK for Java 4.0 supports both of these versions of the protocol. Clients built with this SDK can interact with LDAP v2 servers and LDAP v3 servers.

The LDAP v3 protocol includes these new features:


You can specify controls (both on the server and on the client) that extend the functionality of an LDAP operation.

You can request the server to perform extended operations (beyond the standard LDAP operations).

You can use Simple Authentication and Security Layer (SASL) mechanisms to authenticate to the directory.

Servers have DSEs (DSA-specific entries, where a DSA is a directory server) that provide information including the versions of the LDAP protocol supported, a list of the controls, extended operations, and SASL mechanisms supported by the server, and the naming contexts of the server (specifying the portion of the directory tree managed by this server).

Servers make their schemas available to clients. (You can get a directory server's schema from the root DSE.)

Both client and severs can support data in UTF-8 format. Clients can now request and receive data that is tagged with language information.


此文章相关评论:
该文章有23个相关评论如下:(点这儿可以发表评论)
diag 发表于: 2002/12/23 01:10pm
What's different with OPENLDAP ?  
http://www.openldap.org/  i like it .
 
hutao 发表于: 2002/12/23 01:14pm
一个是opensource的,一个是商业话的,从性能上来说,Netscape Directory Server是业界最好的,比openldap要好的多了!
 
mmmmn 发表于: 2002/12/23 01:15pm
倒,老大不能帮翻译一下啊?
有问题的问,我也每天跟着学:)
 
hutao 发表于: 2002/12/23 01:23pm
老大,我的英语不好啊,不然早就移民了:)
 
mmmmn 发表于: 2002/12/23 01:34pm
移民去找蛙吗?
 
sunmarmot 发表于: 2002/12/23 03:13pm
老大,怎么才能做实验啊??
 
hutao 发表于: 2002/12/23 03:22pm
去www.sun.com下载一个netscape directory server吧
 
windowsnt 发表于: 2002/12/23 04:41pm
 
void 发表于: 2002/12/23 04:51pm
[quote][b]下面引用由[u]hutao[/u]在 [i]2002/12/23 03:22pm[/i] 发表的内容:[/b]
去www.sun.com下载一个netscape directory server吧
[/quote]
solaris9.0自带有
 
hutao 发表于: 2002/12/23 05:11pm
这里有打算移民的吗?:)
 
Ice 发表于: 2002/12/23 05:42pm
俺有这想法 :)
 
coolbid 发表于: 2002/12/23 05:51pm
我害怕,到国外怎样生存,语言不同,文化不同,不过我倒想出去看看,
 
mmmmn 发表于: 2002/12/23 07:45pm
转windowsnt翻译的:

-=-=-=-=-=>
原文http://www.chinaunix.net/cgi-bin/bbs/topic.cgi?forum=3&topic=19145&show=0

翻译的不好,请多多包涵

本章介绍LDAP协议以及与LDAP有关的一些概述

LDAP(Lightweight Directory Access Protocol,轻量级目录访问协议)是一种Internet目录协议

。LDAP是一种用于访问和管理目录服务的协议,由University of Michigan at Ann Arbor与IETF

(Internet Engineering Task Force)合作开发。

本章包括如下内容:
“目录服务是如何工作的”
“LDAP服务器如何组织目录”
“LDAP客户端和服务器如何工作”
“理解LDAP v3协议”
“其他信息”

如果你已经熟悉LDAP,则可以跳过本章,直接从第2章“使用Netscape Directory SDK for JAVA”

开始。

目录服务是如何工作的
目录由包含有描述性信息的各个条目组成。例如,目录可以包含描述人力网络资源的条目,例如打

印机或传真机。
描述性信息存储在每个条目的属性中。每个属性描述一种特定类型的信息。例如,用于描述一个人

的属性可能包括这个人的姓名(公共名称,或cn),电话号码和电子邮件地址。
例如,Barbara Jensen条目可以具有如下属性:
cn: Barbara Jensen
mail: babs@ace.com
telephoneNumber: 555-1212
roomNumber: 3995
一个属性可以具有多个值。例如,一个人可能具有二个公共名称(正式姓名和呢称)或二个电话号码


cn: Jennifer Jensen
cn: Jenny Jensen
mail: jen@ace.com
telephoneNumber: 555-1213
telephoneNumber: 555-2059
roomNumber: 3996
属性还可以包含二进制数据。例如,一个人的属性可能包括这个人的JPEG照片或以声音文件格式录

制的语音。
目录服务是一个分布式数据库应用程序,设计用于管理目录中的条目和属性。目录服务还可以使条

目和属性对于用户和其他应用程序可用。Netscape Directory Server就是一种目录服务。
例如,一个用户可能使用目录服务来查询某个人的电话号码。另一个应用程序可能使用目录服务来

获取电子邮件地址清单。
LDAP是一种协议,用于定义一种目录服务以及如何访问该服务。LDAP基于客户端-服务端模型。

LDAP服务器提供目录服务,LDAP客户端使用目录服务来访问条目和属性。
例如,Netscape Directory Server就是一个LDAP服务器,它管理并提供关于用户和用户组织结构(

例如组或部门)的信息。Netscape Directory Server的HTTP网关,Netscape Navigator,和

Netscape Communicator都是LDAP客户端。该网关使用目录服务来查找、更新和添加关于用户的信

息。

LDAP服务器如何组织目录
LDAP定位于提供全球目录服务,数据按层次结构组织,从一个根开始,向下分支到各个条目。
在层次结构的最顶层,条目代表较大的单位。在这些较大的单位下面,是代表较小单位的条目。层

次结构的最末端可能就是代表某个人或特定资源的条目。
图1.1例示了LDAP目录服务中条目的层次结构。
图1.1 目录中的条目层次结构
每一个条目都由一个名称唯一标识。这个唯一名称由一个在该层次上唯一标识该条目的名称(例如

,bjensen和kjensen是不同的用户ID,在相同层次上标识不同的条目)和一个回溯到根的名称路径

组成。
例如,下面是bjensen条目的唯一名称:
uid=bjensen, ou=People, o=Airius.com
这里,uid代表该条目的用户ID,ou代表该条目所属的组织单元,o代表该条目所属的更大组织。

图1.2 目录中唯一名称范例

目录中存储的数据可以分布在多个LDAP服务器上。例如,一个位于Airius.com的LDAP服务器可以包

含代表北美组织单元和职员的条目,而另一个LDAP服务器可能包含代表欧洲组织单元和职员的条目


有些LDAP服务器设置成引用对其他LDAP服务器的请求。例如,如果位于Airius.com的LDAP服务器接

收到关于Pacific Rim分枝机构中一个职员的信息的请求,LDAP服务器可以作为唯一目录信息源出

现。即使LDAP服务器没有包含所请求的信息,该服务器也可以将请求转到包含有该信息的另一台

LDAP服务器。


LDAP客户端和服务器如何工作
在LDAP客户端-服务器模型中,LDAP服务器(例如Netscape Directory Server)提供关于人、单位和

资源的信息给LDAP客户端使用。LDAP协议定义了一些操作,客户端可以用来搜索和更新目录。LDAP

客户端可以执行如下一些操作:
从目录中搜索并获取条目
添加新条目到目录中
更新目录中的条目
从删除中删除条目
重命名目录中的条目
例如,要更新目录中的一个条目,LDAP客户端将该条目的唯一名称及新的属性信息提交给LDAP服务

器。LDAP服务器使用唯一名称查找该条目,并执行修改操作,更新目录中的相应条目。
要执行这些LDAP操作,LDAP客户端需要与LDAP服务器建立一个连接。LDAP协议指定使用TCP/IP端口

号389,但是有些服务器也在其他端口上运行。
LDAP协议还定义了一种简单的认证方法。可以设置LDAP服务器以限制目录访问权限。在LDAP客户端

可以对LDAP服务器执行操作之前,客户端必须提供一个唯一名称和口令,通过服务器的认证。如果

唯一名称所标识的用户没有执行操作的权限,则服务器将不执行操作。

理解LDAP v3协议
许多LDAP服务器支持LDAP协议版本2。这个协议版本在RFC1777中指定(在

http://www.ietf.org/rfc/rfc1777.txt可以找到该RFC的副本)。
最新提出的标准是LDAP协议版本3,它在RFC2251中定义(可以在http://www.ietf.org/rfc/rfc2551

.txt找到该RFC的副本)。有些LDAP服务器,例如Netscape Directory Server 3.0及以后版本),支

持这个新版本的LDAP协议。
LDAP v3协议包括如下新特征:
可以指定控制(在服务器上和客户端上),扩展LDAP操作的功能。
可以请求服务器执行扩展操作(超越标准LDAP操作)。
可以使用简单认证安全层(SASL,Simple Authentication and Security Layer)机制进行目录认证


服务器使用DSE(DSA特定条目,其中DSA是一个目录服务器)提供信息,包括支持的LDAP协议版本,

控制列表,扩展操作,服务器支持的SASL机制,以及服务器的名称环境(指定该服务器所管理的目

录树部分)。
服务器提供它们的方案给客户端。(你可以从根DSE获得目录服务器的方案)。
客户端和服务器都支持UTF-8格式的数据。客户端现在可以请求并接收用语言信息标记的数据。


-=-=-=-=-=>

 
mmmmn 发表于: 2002/12/23 07:47pm
看这里介绍的感觉和目录的组织形式很类似啊,第一天的概念比较简单。
理解了就好,主要注意是CS模式的,一般使用389这个端口,支持sasl(没所是不是支持sasl2)。
还有什么要重点注意的?hutao给说说
 
段誉 发表于: 2002/12/23 09:22pm
好啊,又有的学了,:)
 
hutao 发表于: 2002/12/23 09:50pm
LDAP的概念很简单,其中有几个重点,大家要知道:

1:schema的定义和它的一种继承关系

2:LDAP的一些命令的使用

3:ACL的使用

 
laoxia 发表于: 2002/12/24 00:23am
移民慎行,经济不景气,IT泡沫破裂,程序员市场还马马虎虎,搞网络和系统的找工
作较难。近一两年来加拿大这边的电脑人找不到工作比比皆是。

看到很多在国内很风光的人折戟沉沙, 很多人后悔。尤其英文不过关,更要慎之又慎。莫斯科不相信眼泪,哪都是的。当然,如果你适应得好,即享受到中国文化中的精粹, 又喜
欢西方文化里的精华,那里就赚了。就怕你看电视也看不出乐,看书也不乐,就想
听相声,那就太累了。而这一切,和你的外语关系最大。你想,语言不好可以认为
是一种残疾,和本地以英文为母语的人竞争是一大劣势。当然,随时间推移会英文
越来越好。但出国这事本身对一个人冲击是不小的,方方面面要调好心态才行。

 
hutao 发表于: 2002/12/24 00:27am
laoxia,你在那里啊,可否传授一点经验啊:)
 
laoxia 发表于: 2002/12/24 00:32am
俺在多伦多那,俺就是失业,公司被卖了,都回家了。现在是有工作的不敢跳,新增
机会又很少,所以系统跟网络的挺难的。你想知道什么,俺真是老华侨了。
 
laoxia 发表于: 2002/12/24 07:11am
希望不要吓着大家啊,还是有很多人发展不错,我给大家的意见只是我觉得你要想出
来,一定要作好各种思想准备。出来之前作好积累,包括思想上的,经济上的,技
术上的。只是想告诉大家,出国当然可以换一种法,但国外并非天堂。
 
VanGogh 发表于: 2002/12/24 09:46am
辛苦了,谢谢!
弱弱的问一下:
ldap的功能特点是什么?说它是C/S模式,分部式管理数据库,那么和数据库,或http,xml的什么不同?
 
llc107 发表于: 2002/12/25 10:04am
辛苦各位大侠了!!
 
wdq007 发表于: 2002/12/25 03:06pm
我来说说ldap和数据库的关系,目录服务偏重的是访问数据的速度,因此在数据访问组织结构这一层上做了许多优化,所以它的数据查询访问速度比数据库快了很多,但是它的数据写入速度相对较慢,读出和写入速度相差可达一个数量级别,适用于数据不需要经常改动,但需要频繁读出的情况,比如邮件系统的用户信息一般都储存在ldap中,而不是数据库中。

ldap服务器之间支持相互之间的复制,在某些方面和分布式数据库有类似之处,至于与http和xml有什么不同,显而易见吧,风牛马不相及,xml只是数据的一种表示方式,http是协议,几句话说不清楚,楼上面问这个问题的老兄请先入入门,看看xml,http的定义就会明白的

 
 

Copyright © ChinaUnix.net  *  转载请注明出处及作者