LDAP定义schema详解

schema类似关系数据库的字段说明,包括字段名,数据类型,数据长度等等。系统有一些默认的schema,我的默认schema文件
在/usr/local/openldap/etc/openldap/schema下面,最重要的是core.schema。它定义了一些最基本的字段。
为了适应我们的应用,我们要创建自己的schema文件。我创建的shema文件如下:(文件名:kunmail.schema)
#
# kunmail-ldap v3 directory schema
#
# written by MSN:zhoujianguo_leo@hotmail.com
#
# Attribute Type Definitions
attributetype ( 1.3.6.1.4.1.7914.1.2.1.1 NAME 'username'
DESC 'name of the user on the mailsystem'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-value )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.2 NAME 'vuid'
DESC 'UID of the user on the mailsystem'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-value )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.3 NAME 'vgid'
DESC 'GID of the user on the mailsystem'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-value )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.4 NAME 'maildir'
DESC 'Path to the maildir/mbox on the mail system'
EQUALITY caseExactMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
SINGLE-value )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.5 NAME 'forwardAddr'
SUBSTR caseIgnoreSubstringsMatch
DESC 'Forward mail address'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.6 NAME 'quota'
DESC 'The amount of space the user can use until all further messages get bounced.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.44
SINGLE-value )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.7 NAME 'storeHost'
DESC 'On which kunmail server the messagestore of this user is located.'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-value )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.8 NAME 'delivery'
DESC 'Program to execute for all incoming mails.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
SINGLE-value )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.9 NAME 'clearpw'
DESC 'name of the user on the mailsystem'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-value )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.10 NAME 'home'
DESC 'Program to execute for all incoming mails.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
SINGLE-value )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.11 NAME 'mailReplyText'
DESC 'A reply text for every incoming message'
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{4096}
SINGLE-value )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.12 NAME 'active'
DESC 'The status of a user account: active, nopop, disabled'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-value )
# Object Class Definitions
objectclass ( 1.3.6.1.4.1.7914.1.2.2.1 NAME 'kunmailUser'
DESC 'KunMail-LDAP User' SUP top STRUCTURAL
MUST ( username $ cn $ vuid $ vgid )
MAY ( maildir $ home $ clearpw $
forwardAddr $ quota $
storeHost $ delivery $
mailReplyText $ active ) )
现在来说说这个schema文件。
开始部分是attributeType的定义,相当于字段定义。最后的objectclass是定义数据所包含的属性。
这里kunmailUser这种数据,要包含maildir $ home $ clearpw $ forwardAddr $ quota $ storeHost $ delivery $ mailReplyText $ active
等可选项,还要包括username $ cn $ vuid $ vgid 必选项。 可选项用MAY()来包含,必选项用MUST()来包含。DESC是说明项。SUP表示父类(
有点像面向对象编程啊)top表示没有父类,他自己是顶级。STRUCTURAL是存储方式,不管他(我也说不清楚)
接下来解释attributeType的说明项。
第一个数字是表示序号,至少我是怎么认为的,也许不对,不过。。。管他。
NAME是表示属性的名字
DESC是说明
下面表示的是匹配的方式,SUBSTR是字符串匹配,EQUALITY是相等性匹配,这些在openldap的admin guide里面有,不难看懂
SYNTAX是表示字段的数据类型。这个admin guide里面也有说明。
SINGLE-value表示这个属性只有一个值,有些属性可以有多个值,比如联系地址等。默认的话,是多值的。

schema准备好之后,我们要在配置文件中,把这个schema包含进去,让这个schema生效。
在配置文件slapd.conf中间的开始部分加入这样的一句:
include /usr/local/openldap/etc/openldap/schema/kunmail.schema
应该注意,上面这句话之前应确保有一句:
include /usr/local/openldap/etc/openldap/schema/core.schema
因为kunmail.schema里面有些东西是依赖core.schema的。
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值