📄 1876.html
字号:
<DIV align=right><FONT class=normalfont>当前位置:
<A href="index.html" tppabs="http://www.linuxhero.com/docs/index.html">本站首页</A>
<font color="#FF6699">>></font>
<A href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</A> | <A href="copyright.html" tppabs="http://www.linuxhero.com/docs/copyright.html">版权说明</A></font></DIV>
</TD>
<TD><IMG height=22 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1
border=0></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=10 cellPadding=0 width="100%" bgColor=#ffffff
border=0>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
<TR>
<TD vAlign=top align=middle width="60%">
<TABLE cellSpacing=0 cellPadding=0 width="100%"
background="images/back.gif" tppabs="http://www.linuxhero.com/docs/images/back.gif" border=0>
<TBODY>
<TR>
<TD vAlign=top width="80%">
<DIV align=center>
<FORM action="search.html" tppabs="http://www.linuxhero.com/docs/search.html" method=get>
</FORM>
<TABLE cellSpacing=0 cellPadding=0 width="95%"
border=0><TBODY>
<TR>
<TD background="images/bgi.gif" tppabs="http://www.linuxhero.com/docs/images/bgi.gif"
height=30></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=3 width="95%"
align=center border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%"
border=0>
<TBODY>
<TR>
<TD vAlign=top>
<p><FONT class=normalfont><B><font color=blue>设置一个基本的OpenLDAP Server</font></B></FONT><BR><FONT class=smallfont color=#ff9900>2004-04-23 15:18 pm</FONT><BR><FONT class=normalfont>作者:吴阿亭 (Jephe Wu)<br>来自:Linux知识宝库<br>联系方式:无名<br><br>一. 目的 <br>
<br>
本文旨在介绍如何安装OpenLDAP并且设置一个公司内部的集中化的邮件地址薄服务器供客户端查询。 <br>
基本上,OpenLDAPg还应用在其它许多方面,象集中化的用户帐号验证服务器,但邮件地址薄查询是最常用的。<br>
<br>
二. 安装 <br>
<br>
从www.openldap.org下载最新的openldap软件包,按照编译和安装的步骤,依次运行:<br>
<br>
<br>
#tar cvfz openldap-stable-20010524.tgz <br>
#cd openldap-2.0.11 <br>
#./configure <br>
#make depend <br>
#make <br>
#make test <br>
#make install <br>
<br>
我的操作环境是redhat 6.1,如果没有遇到任何错误,最后默认安装LDAP后台程序slapd到目录/usr/local/libexec;配置文件在目录/usr/local/etc/openldap/ 并且放各种OpenLDAP工具<br>
ldapadd,ldapdelete,ldapmodify,ldapmodrdn,ldappasswd,ldapsearch在目录/usr/local/bin,运行时数据库在/usr/local/var/openldap-ldbm。<br>
<br>
<br>
三. 设置 <br>
<br>
1) 更改配置文件/usr/local/etc/openldap/slapd.conf<br>
在include /usr/local/etc/openldap/schema/core.schema这行后面加上下面的行,包括所有的方案。 <br>
<br>
include /usr/local/etc/openldap/schema/corba.schema <br>
include /usr/local/etc/openldap/schema/cosine.schema <br>
include /usr/local/etc/openldap/schema/inetorgperson.schema <br>
include /usr/local/etc/openldap/schema/java.schema <br>
include /usr/local/etc/openldap/schema/krb5-kdc.schema <br>
include /usr/local/etc/openldap/schema/misc.schema <br>
include /usr/local/etc/openldap/schema/nadf.schema <br>
include /usr/local/etc/openldap/schema/nis.schema <br>
include /usr/local/etc/openldap/schema/openldap.schema <br>
<br>
2) 在文件slapd.conf的"ldbm database definitions"部分更改相应的suffix,rootdn行如下 <br>
<br>
database ldbm <br>
suffix "o=yourdomain,c=us" <br>
rootdn "cn=root,o=yourdomain,c=us" <br>
rootpw secret <br>
directory /usr/local/var/openldap-ldbm <br>
<br>
有各种格式你可以用,这里我用的是o=yourdomain,c=us 说明你的公司域名和所在的国家或地区。<br>
rootdn的格式安装后默认为cn=Manager,这里改为root完全是自己的喜好,这样符合Unix/Linux中root具有最高权限的传统。 <br>
<br>
3) 现在可以启动slapd了,运行/usr/local/libexec/slapd 。 <br>
<br>
可以考虑把/usr/local/bin and /usr/local/libexec加到搜索路径中,即加到/etc/profile<br>
中的PATH行: <br>
PATH="$PATH:/usr/X11R6/bin:/usr/local/bin:/usr/local/libexec" <br>
这样下次登录后只需键入 slapd 。 <br>
<br>
4) 测试ldap server是否正常工作。 <br>
运行下面的命令检查是否有相应的输出。 <br>
<br>
#ldapsearch -x -b 'o=yourdomain,c=us' '(objectclass=*)' <br>
陈绪先生注:有误,应该为<br>
ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts<br>
或者<br>
ldapsearch -x -b '' -s base '(objectclass=*)'<br>
<br>
5) 编辑.ldif文本文件,用ldapadd添加记录进入LDAP数据库。 <br>
文件内容如下: <br>
<br>
dn: o=yourdomain,c=us <br>
objectclass: dcobject <br>
objectclass: organization <br>
o: yourdomain <br>
dc: yourdomain <br>
<br>
dn: cn=Jephe Wu,o=yourdomain,c=us <br>
objectclass: inetorgperson <br>
cn: Jephe Wu <br>
sn: Wu <br>
mail: jephe_wu@yourdomain.com <br>
<br>
<br>
......more users...... <br>
<br>
依次类推,添加每个人的记录进入该文件中,注意对象类型 inetorgperson 至少必须要有cn和sn,这里我们用cn,sn,mail三项定义,这对我们的邮件地址薄功能来说已经足够。你还可以定义象mobile, homephone,pager......等等。 <br>
<br>
然后用下面的命令添加上面的.ldif文件进入LDAP数据库 <br>
<br>
#ldapadd -x -D "cn=root,o=yourdomain,c=us" -w secret -f "yourldiffilename" <br>
<br>
注:上面的文件的第一部分"dn: o=yourdomain,c=us"是必须的,否则不能添加数据。<br>
用你的公司的域名替换上面的"yourdomain"。 <br>
<br>
6) 设置Outlook Express, 允许用LDAP服务器查询邮件地址。 <br>
<br>
"工具/帐号/添加--目录服务",填入你的服务器的IP地址或者主机全称域名,在下一个屏幕中选yes以允许用目录服务来查询地址,最后在"目录服务"栏中选中刚才设置的项目击“属性/高级",在"搜索库"中填入"o=yourdomain,c=us"。<br>
Netscape请根据上面的信息设置相应的选项。<br>
<br>
四. 常见使用问题 <br>
<br>
1) 能启动slapd 没有问题,但不能添加数据库,运行ldapadd添加时出错 "ldap_bind:cannot contact LDAP Server" 。 <br>
答: 最可能的原因是在/etc/hosts中没有127.0.0.1 localhost项目。 <br>
<br>
2) 注意查询顺序: 如果在Outlook Express的地址薄中有内容,则检查地址时地址薄优先,如果在本地地址薄中找不到相应记录,然后再查询LDAP服务器。 <br>
<br>
3) 用下面的命令确信客户端与LDAP服务器有通讯,在服务器运行下面的命令,然后在OE中测试检查地址,你将会得到查询LDAP数据库的连接过程的输出。<br>
<br>
# tcpdump port 389
</FONT><br>
</TD>
</TR>
<TR>
<TD colSpan=2><FONT
class=middlefont></FONT><BR>
<FONT
class=normalfont>全文结束</FONT> </TD>
</TR>
<TR>
<TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2
height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
<TD vAlign=top width="20%"
background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2>
<DIV align=center>
<table class=tableoutline cellspacing=1 cellpadding=4
width="100%" align=center border=0>
<tr class=firstalt>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
<font class=normalfont><b>所有分类</b></font></td>
</tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td> </tr> </table></td></tr> </table>
</DIV></TD></TR>
<TR vAlign=top>
<TD width="80%">
<DIV align=center><BR>
</DIV>
</TD></TR></TBODY></TABLE></TD></TR>
</TABLE></TD></TR>
</TABLE>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee
border=0><TBODY>
<TR>
<TD width="50%">
<P><FONT class=middlefont>版权所有 © 2004 <A
href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
违者必究. </FONT></P>
</TD>
<TD width="50%">
<DIV align=right><FONT class=middlefont>Powered by: <A
href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
</TD></TR></TBODY></TABLE>
<CENTER></CENTER></TD></TR>
</TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -