我是LDAP新手并搜索添加简单的objectClass和Attributes但仍然出错, 我想有一个带有简单字符串属性'functionId'的对象'adminFunc',所以我将adminFunc.schema和adminFunc.ldif复制到架构文件夹中:
adminFunc.schema:
objectidentifier adminFuncSchema 1.3.6.1.4.1.X.Y
objectidentifier funcAttrs adminFuncSchema:3
objectidentifier funcClass adminFuncSchema:4
attributetype ( funcAttrs:2
NAME 'functionId'
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
ORDERING caseIgnoreOrderingMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{255} )
objectclass (
funcClass:1
NAME 'adminFunc'
DESC 'Admin permission'
SUP ( top ) AUXILIARY
MAY functionId )
adminFunc.ldif:(已通过运行slaptest自动生成)
dn: cn=adminFunc
objectClass: olcSchemaConfig
cn: adminFunc
olcObjectIdentifier: adminFuncSchema 1.3.6.1.4.1.X.Y
olcObjectIdentifier: funcAttrs adminFuncSchema:3
olcObjectIdentifier: funcClass adminFuncSchema:4
olcAttributeTypes: ( funcAttrs:2 NAME 'functionId' EQUALITY caseIgnoreMat
ch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{255} )
olcObjectClasses: ( funcClass:1 NAME 'adminFunc' DESC 'Admin permission'
SUP top AUXILIARY MAY functionId )
structuralObjectClass: olcSchemaConfig
entryUUID: c43389f4-0bfb-1037-959b-c9dc976d6fc3
creatorsName: cn=config
createTimestamp: 20170802182555Z
entryCSN: 20170802182555.047279Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20170802182555Z
modify.ldif 我的dn是ou = Local,ou = SV,dc = example,dc = com
尝试运行此命令以创建新的Call_Center对象:
ldapmodify -x -W -D“cn = ldapadmin,dc = example,dc = com”-f modify.ldif
dn: cn=Call_Center,ou=Local,ou=SV,dc=example,dc=com
changetype: add
objectClass: top
objectClass: adminFunc
cn: Call_Center
functionId: 1010
但是找不到我的adminFunc对象:
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry "cn=Call_Center,ou=Local,ou=SV,dc=example,dc=com"
ldap_add: Invalid syntax (21)
additional info: objectClass: value #1 invalid per syntax
不确定我错过了什么。
由于
答案 0 :(得分:3)
这些是我在openldap中创建新对象和属性的步骤:
#Attribute definition
attributetype ( 1.3.6.1.4.1.42.2.27.4.1.6
NAME 'sampleAttribute'
DESC 'Sample Attribute'
EQUALITY caseExactMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
SINGLE-VALUE )
#Object Class Definition
objectclass ( 1.3.6.1.4.1.42.2.27.4.2.1
NAME 'SampleObject'
DESC 'Sample object'
SUP top
STRUCTURAL
MUST ( cn $ sampleAttribute ) )
包括/home/test.schema
#create目录
mkdir testdir
#run slaptest
slaptest -f test.conf -F testdir
生成的文件将是testdir / cn = config / cn = schema / cn = {0} test.ldif,看起来像这样(经过一些手动编辑后):
# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
# CRC32 f74b018a
dn: cn=sample,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: sample
olcAttributeTypes: {0}( 1.3.6.1.4.1.42.2.27.4.1.6 NAME 'sampleAttribute'
DESC 'Sample Attribute' EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.
121.1.15 SINGLE-VALUE )
olcObjectClasses: {0}( 1.3.6.1.4.1.42.2.27.4.2.1 NAME 'SampleObject' DESC 'Sam
ple object' SUP top STRUCTURAL MUST ( cn $ sampleAttribute ) )
structuralObjectClass: olcSchemaConfig
entryUUID: 4a10b3ec-4aca-1036-997a-3fcaae1517d7
creatorsName: cn=config
createTimestamp: 20161129215530Z
entryCSN: 20161129215530.381328Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20161129215530Z
我将我的名字重命名为sample.ldif。
在服务器上,运行:
service slapd stop
slapadd -l sample.ldif -n 0
#to populate the config database slapd-config(5), use -n 0 as it is always the first database.
service slapd start