openldap配置笔记

安装:
# yum search openldap
# yum install openldap-servers
# yum install openldap-clients


配置:
slapd有个配置文件,
/etc/openldap/slapd.d 和 /etc/openldap/slapd.conf。
rpm默认安装slapd.d。
为了使用slapd.conf,需要把/etc/openldap/slapd.d改名,
然后创建slapd.conf。

include /etc/openldap/schema/core.schema
database bdb
suffix "dc=sy,dc=cn"
rootdn "cn=Manager,dc=sy,dc=cn"
rootpw shenyue
#directory /var/lib/ldap
directory /var/lib/openldap
pidfile /var/run/openldap/slapd.pid


注意,如果没有配置文件(slapd.d或slapd.conf都不存在)
执行slapd后没有任何信息,也启动不了,而且不会报错。

如果没有include core.schema,slaptest报错。
“<suffix> invalid DN 21 (Invalid syntax)”

开启SELinux时要注意权限。
chcon -R --reference /var/lib/ldap /var/lib/openldap/

启动:
使用slaptest测试配置是否正确。
# slaptest
# ps -ef|grep slapd

# config指定的数据库目录。需要所有者为ldap,权限为600
# ll /var/lib/openldap

# rpm默认安装的数据库在/var/lib/ldap/下。
# ll /var/lib/ldap/

# service slapd stop
# service slapd start

# service slapd status



检索ldapsearch:


# ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts

# ldapadd -x -D "cn=Manager,dc=test,dc=com" -W -f ex.ldif

       -LLL

       -v     Run in verbose mode, with many diagnostics written to standard output.

       -h ldaphost
              Specify an alternate host on which the ldap server is running.  Deprecated in favor of -H.

       -x     Use simple authentication instead of SASL.

       -D binddn
              Use  the  Distinguished Name binddn to bind to the LDAP directory.  For SASL binds, the server
              is expected to ignore this value.

       -W     Prompt for simple authentication.  This is used instead of specifying the password on the com-
              mand line.

       -w passwd
              Use passwd as the password for simple authentication.


       -p ldapport
              Specify  an alternate TCP port where the ldap server is listening.  Deprecated in favor of -H.

       -b searchbase
              Use searchbase as the starting point for the search instead of the default.

       -s {base|one|sub|children}
              Specify the scope of the search to be one of base, one, sub, or children  to  specify  a  base
              object,  one-level,  subtree,  or  children search.  The default is sub.  Note: children scope
              requires LDAPv3 subordinate feature extension.

        filter例

               objectclass=person       检索含有person及其子类(如inetOrgPerson)的记录

               sn       检索含有sn的记录,即使sn为空也会被检索。想检索sn不为空的记录,指定sn=*

               cn=Manager       检索cn的值为Manager的记录。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值