openLDAP

LDAP :

yum 安装

yum install openldap-*

安装后openLDAP的软件名称为slapd

相关配置文件的存放目录为:

/etc/openldap

初始提供的配置文件模板在

/usr/share/openldap-servers
<pre name="code" class="plain">#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#

include		/etc/openldap/schema/corba.schema
include		/etc/openldap/schema/core.schema
include		/etc/openldap/schema/cosine.schema
include		/etc/openldap/schema/duaconf.schema
include		/etc/openldap/schema/dyngroup.schema
include		/etc/openldap/schema/inetorgperson.schema
include		/etc/openldap/schema/java.schema
include		/etc/openldap/schema/misc.schema
include		/etc/openldap/schema/nis.schema
include		/etc/openldap/schema/openldap.schema
include		/etc/openldap/schema/ppolicy.schema
include		/etc/openldap/schema/collective.schema

# Allow LDAPv2 client connections.  This is NOT the default.
allow bind_v2

# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral	ldap://root.openldap.org

pidfile		/var/run/openldap/slapd.pid
argsfile	/var/run/openldap/slapd.args

# Load dynamic backend modules
# - modulepath is architecture dependent value (32/64-bit system)
# - back_sql.la overlay requires openldap-server-sql package
# - dyngroup.la and dynlist.la cannot be used at the same time

# modulepath /usr/lib/openldap
# modulepath /usr/lib64/openldap

# moduleload accesslog.la
# moduleload auditlog.la
# moduleload back_sql.la
# moduleload chain.la
# moduleload collect.la
# moduleload constraint.la
# moduleload dds.la
# moduleload deref.la
# moduleload dyngroup.la
# moduleload dynlist.la
# moduleload memberof.la
# moduleload pbind.la
# moduleload pcache.la
# moduleload ppolicy.la
# moduleload refint.la
# moduleload retcode.la
# moduleload rwm.la
# moduleload seqmod.la
# moduleload smbk5pwd.la
# moduleload sssvlv.la
# moduleload syncprov.la
# moduleload translucent.la
# moduleload unique.la
# moduleload valsort.la

# The next three lines allow use of TLS for encrypting connections using a
# dummy test certificate which you can generate by running
# /usr/libexec/openldap/generate-server-cert.sh. Your client software may balk
# at self-signed certificates, however.
TLSCACertificatePath /etc/openldap/certs
TLSCertificateFile "\"OpenLDAP Server\""
TLSCertificateKeyFile /etc/openldap/certs/password

# Sample security restrictions
#	Require integrity protection (prevent hijacking)
#	Require 112-bit (3DES or better) encryption for updates
#	Require 63-bit encryption for simple bind
# security ssf=1 update_ssf=112 simple_bind=64

# Sample access control policy:
#	Root DSE: allow anyone to read it
#	Subschema (sub)entry DSE: allow anyone to read it
#	Other DSEs:
#		Allow self write access
#		Allow authenticated users read access
#		Allow anonymous users to authenticate
#	Directives needed to implement policy:
# access to dn.base="" by * read
# access to dn.base="cn=Subschema" by * read
# access to *
#	by self write
#	by users read
#	by anonymous auth
#
# if no access controls are present, the default policy
# allows anyone and everyone to read anything but restricts
# updates to rootdn.  (e.g., "access to * by * read")
#
# rootdn can always read and write EVERYTHING!

# enable on-the-fly configuration (cn=config)
database config
access to *
	by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage
	by * none

# enable server status monitoring (cn=monitor)
database monitor
access to *
	by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read
        by dn.exact="cn=Manager,dc=my-domain,dc=com" read
        by * none

#######################################################################
# database definitions
#######################################################################

database	bdb
suffix		"dc=my-domain,dc=com"
checkpoint	1024 15
rootdn		"cn=Manager,dc=my-domain,dc=com"
# Cleartext passwords, especially for the rootdn, should
# be avoided.  See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
# rootpw		secret
# rootpw		{crypt}ijFYNcSNctBYg

# The database directory MUST exist prior to running slapd AND 
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory	/var/lib/ldap

# Indices to maintain for this database
index objectClass                       eq,pres
index ou,cn,mail,surname,givenname      eq,pres,sub
index uidNumber,gidNumber,loginShell    eq,pres
index uid,memberUid                     eq,pres,sub
index nisMapName,nisMapEntry            eq,pres,sub

# Replicas of this database
#replogfile /var/lib/ldap/openldap-master-replog
#replica host=ldap-1.example.com:389 starttls=critical
#     bindmethod=sasl saslmech=GSSAPI
#     authcId=host/ldap-master.example.com@EXAMPLE.COM

 

默认slapd 绑定的端口为389

openldap 查询:

ldapsearch 参数:

参数	用途
-?	打印关于使用 ldapsearch 的帮助。
-a deref	指定别名反向引用。请输入 never、always、search 或 find。如果不使用此参数,缺省为 never。
-A	只检索属性的名称,而不检索属性的值。
-b base dn	指定用作搜索起始点的专有名称。使用引号来指定该值,例如:"ou=West,o=Acme,c=US"
如果要搜索的服务器需要指定搜索起点,则必须使用此参数。否则此参数是可选的。

也可以同时使用 -b 和 -s 来确定搜索范围。没有 –s,-b 就会搜索指定为起始点的项以及该项的所有子项。

-B	允许打印非 ASCII 值
-D bind dn	指定服务器用于验证您的专有名称。名称必须与目录中的项相符,并且必须拥有搜索目录所需的权限。
请使用引号来指定该名称,例如:"cn=Directory Manager,o=Acme,c=US"

如果不使用此参数,则与服务器的连接是匿名的。如果服务器不允许匿名连接,则必须使用 -D。

除了 -D,还必须使用 -w 参数来指定与专有名称相关联的口令。

-f file	指定包含要使用的搜索过滤器的文件,如 -f 过滤器。请将每个搜索过滤器置于单独的一行。Ldapsearch 会对每一行执行一次搜索。可选择指定过滤模式。例如,指定 -f 过滤 "cn=%s",并在文件的每一行中输入公用名称的值。
-F sep	在属性名称和值之间打印 sep 而不是等号 (=)。例如,如果读取 ldapsearch 输出的工具希望使用其他的分隔符时,可以使用此参数。
-h host name	指定要连接的服务器主机名,如 -h server.acme.com。
-l timelimit	指定完成搜索的时间限制(秒)。如果没有指定此参数或指定的限制为 0,那么搜索就没有时间限制。但是,ldapsearch 的等待时间决不会超过服务器上设置的搜索时间限制。
-L	指定以 LDIF 格式输出。LDIF 格式使用冒号 (:) 而不是等号 (=) 作为属性描述符。LDIF 对一次性添加或修改大量目录项很有帮助。例如,可以将输出内容引入兼容 LDAP 的目录中。
-M	将参考对象作为普通项进行管理,以使 ldapsearch 可返回参考项本身的属性,而不是所参考的项的属性。
-n	显示如何执行搜索,但不实际执行搜索
-p port	指定服务器使用的端口。如果没有使用此参数,缺省情况下 ldapsearch 使用 389 端口。
-R	不自动遵循服务器返回的搜索引用。请注意,Netscape 目录服务器将术语 referrals 用于搜索引用。
-s scope	指定使用 -b 参数时的搜索范围:
base -- 仅搜索 -b 参数指定的项
onelevel -- 仅搜索 -b 参数指定项的直接子项,而不搜索该项本身
subtree -- 搜索 -b 参数指定的项以及它的所有子项。这是不带 -s 时使用 -b 的缺省行为。
指定 -b 和 -s 的顺序并不重要。
-S attribute	按指定的属性排序结果。
-z sizelimit	指定返回项的最大数目。如果没有指定此参数或指定的限制为 0,那么返回的项没有数量限制。但是,ldapsearch 返回的项决不会多于服务器允许的数量。
-u	指定 ldapsearch 以用户友好格式返回专有名称。
-v	指定 ldapsearch 以详尽模式运行。
-w password	指定与 -D 参数一起使用的与专有名称关联的口令。
x	与 -S 一起使用时可指定 LDAP 服务器在将结果返回之前就对它们进行排序。如果使用 -S 而不使用 –x,ldapsearch 将对结果排序。
ldapsearch 搜索过滤器中使用的运算符表 
下表描述了可以在搜索过滤器中使用的运算符。
运算符	用途	样例
=	查找所包含的属性值与指定值相同的项	"cn=John Browning"
= <string>*<string>	查找所包含的属性值与指定的子字符串相同的项	"cn=John*"
"cn=J*Brown"

>=	查找特定项,该项中包含的属性的数字或字母值大于或等于指定的值。	"cn>=D"
<=	查找特定项,该项中包含的属性的数字或字母值小于或等于指定的值。	"roomNumber<=300"
=*	查找包含特定属性的值的项,而不用管属性的值是什么。	"sn=*"
~=	查找特定项,该项中所含属性的值约等于指定的值。	"sn~=Brning" 可能返回 sn=Browning
&	查找与所有搜索过滤器中指定的条件相匹配的项	"(&(cn=John Browning)(l=Dallas))"
|	查找与至少一个搜索过滤器中指定的条件相匹配的项	"(|(cn=John Browning)(l=Dallas))"
!	查找与任何搜索过滤器中指定的条件都不匹配的项	"(!(cn=John Browning)(l=Dallas))"


ldapsearch -D 'dc=niem,dc=internel' -w secret  -b 'dc=niem,dc=internel' 'cn=niem' 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值