LDAP学习——(2)OpenLdap安装

来源:互联网 发布:java如何实现抢单功能 编辑:程序博客网 时间:2024/06/02 01:03

一、OpenLdap是什么

OpenLDAP是轻型目录访问协议(Lightweight Directory Access Protocol,LDAP)的自由和开源的实现,在其OpenLDAP许可证下发行,并已经被包含在众多流行的Linux发行版中。

它主要包括下述4个部分:

  • slapd - 独立LDAP守护服务
  • slurpd - 独立的LDAP更新复制守护服务
  • 实现LDAP协议的库
  • 工具软件和示例客户端

简单的说,它就是一个ldap服务器~~

二、OpenLdap安装


随便搜索下OpenLdap安装包,傻瓜式一直下一步就可以了。

三、OpenLdap配置

安装完OpenLdap后,编辑安装目录下的slapd.conf文件:

1)找到【ucdata-path    ./ucdata】这个东东(第四行左右),下面有一堆的include,初始的默认配置只include一些schema(这些schema是ldap目录包含的objectClass,OpenLdap已经将一些常用的objectClass帮我们编辑好了,具体可以看OpenLdap安装目录下的schema目录),这里我把schema目录下的所有文件都include进去(有总比没有好~):

include ./schema/corba.schemainclude ./schema/core.schemainclude ./schema/dyngroup.schemainclude ./schema/java.schemainclude ./schema/misc.schemainclude ./schema/cosine.schemainclude ./schema/nis.schemainclude ./schema/inetorgperson.schemainclude ./schema/openldap.schema
2)找到【suffix】(可以认为是你的openldap服务的基本域,类似你的网址域名一样的概念)和【rootdn】(root用户的dn,以后用root用户登录要用这个dn),我的编辑如下:

suffix"o=anotherbug,c=com"rootdn"cn=root,o=anotherbug,c=com"

3)找到【rootpw】,修改root用户的密码,这里是明文【secret】,不安全,我们改成md5加密的形式

首先cmd进入黑黑的windows命令行界面,打开openLdap的安装目录,然后输入命令

slappasswd -h {md5} -s secret

这时候会提示你输入密码两次,输入123456,返回一个MD5字符串粗来,例如:

{MD5}4QrcOUm6Wau+VuBX8g+IPg==

复制这块内容,代替【secret】(注意:rootpw和密码之间不能有空格,但是可以用tab间隔)

4)启动OpenLdap,cmd进入黑黑的windows命令行界面,打开openLdap的安装目录,然后输入命令

slapd -d 1
可以看到控制台下打印一片信息,openldap 默认是用的Berkeley DB 数据库存储目录数据的。

当然,也可以打开window是的【启动任务管理器】,然后进入【服务】面板,点击右下角的【服务】按钮,可以打开windows的服务窗口,在里面查找【OpenLDAP Directory Service】,然后启动或者重新启动啥的,可以不用打开命令窗口进行操作。

四、数据录入

新建一个文本文件,改名为test.ldif,添加以下内容(内容就不做说明了,objectClass表明了一个dn所能拥有的属性,有必填也有非必填的):

dn: o=anotherbug,c=comobjectClass: dcObjectobjectClass: organizationo: anotherbugdc: comdn: uid=admin,o=anotherbug,c=comuid: adminobjectClass: inetOrgPersonmail: admin@gmail.comuserPassword: adminlabeledURI: http://anotherbug.com/blogsn: sn_admincn: admindn: uid=test01,o=anotherbug,c=comuid: test01objectClass: inetOrgPersonmail: test01@gmail.comuserPassword: test01labeledURI: http://anotherbug.com/blogsn: sn_test01cn: test01dn: uid=test02,o=anotherbug,c=comuid: test02objectClass: inetOrgPersonmail: test02@gmail.comuserPassword: test02labeledURI: http://anotherbug.com/blogsn: sn_test02cn: test02
然后cmd进入黑黑的windows命令行界面,打开openLdap的安装目录,然后输入命令(cn=root,o=anotherbug,c=com是rootdn,123456是rootdn的密码):

ldapadd -c -x -D "cn=root,o=anotherbug,c=com" -w 123456 -f test.ldif

操作成功即可添加3个用户(admin,test01,test02)

五、Softerra LDAP Browser

Softerra LDAP Browser是一个ldap的查看界面,可以查看ldap目录内容。

1)安装Softerra LDAP Browser(随便搜索下都有,笔者用的是Softerra LDAP Browser 4.5),也是傻瓜式下一步安装

2)打开Softerra LDAP Browser,新建一个连接,直接看图吧


输入连接名称:


输入ip地址和basedn,端口默认是389:


输入rootdn和root密码(当然也可以是刚刚新加的一个用户dn:uid=admin,o=anotherbug,c=com,密码是admin):


然后粗线这个算成功了!



这里只是介绍简单的安装和连接方式,其中一些细节和一些报错的东西没做介绍,如果大家有什么不明白地方自己百度吧,网上资料挺多的~


0 0