OpenLDAP:將 olcObjectClass 加入到方案中

OpenLDAP:將 olcObjectClass 加入到方案中

我透過 cn=conf 為 OpenLDAP 添加了一個方案。此方案取自 WSO2 Identity Server,但經過修改以適用於 cn=conf 和 OpenLDAP。

該方案載入沒有錯誤,但不起作用。查詢所有載入方案的 cn=schemes,cn=conf 後,我發現我的方案沒有定義方案名稱和內容的 olcObjectClasses 語句。這是我加載的 LDIF 檔案的一部分(沒有錯誤),但由於某種原因不存在於即時配置中。

我現在嘗試事後添加它,但出現錯誤:

ldapmodify: invalid format (line 5) entry: "cn={4}wso2Person,cn=schema,cn=config"

我嘗試加載的文件如下所示:

dn: cn={4}wso2Person,cn=schema,cn=config
changetype: modify
add: olcObjectClasses
olcObjectClasses: ( 0.3.6.1.4.1.37505.1.1
NAME 'wso2Person'
DESC 'wso2Person'
SUP inetOrgPerson
STRUCTURAL
MAY ( gender $ country $ nickName $ timeZone $ dateOfBirth $ role $ im $ url $ otherPhone $ privatePersonalIdentifier $ profileconfiguration $ prefferedLanguage)
)

查詢時:ldapsearch -Y EXTERNAL -H ldapi:/// -b cn=schema,cn=config 有關我的方案的部分如下所示:

# {4}wso2Person, schema, config
dn: cn={4}wso2Person,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: {4}wso2Person
olcAttributeTypes: {0}( 1.3.6.1.4.1.37505.1.2       NAME 'gender'     EQUALI
TY caseIgnoreMatch       SUBSTR caseIgnoreSubstringsMatch       SYNTAX 
1.3.6.
1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: {1}( 1.3.6.1.4.1.37505.1.3       NAME 'country'       
EQUALITY caseIgnoreMatch       SUBSTR caseIgnoreSubstringsMatch       SYNTAX 
1.3.6.1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: {2}( 1.3.6.1.4.1.37505.1.4       NAME 'nickName'     EQUA
LITY caseIgnoreMatch       SUBSTR caseIgnoreSubstringsMatch       SYNTAX 
1.3.6.1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: {3}( 1.3.6.1.4.1.37505.1.5       NAME 'timeZone'       
EQUALITY caseIgnoreMatch       SUBSTR caseIgnoreSubstringsMatch       SYNTAX 
1.3.6.1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: {4}( 1.3.6.1.4.1.37505.1.6       NAME 'dateOfBirth'       
EQUALITY caseIgnoreMatch       SUBSTR caseIgnoreSubstringsMatch       SYNTAX 
1.3.6.1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: {5}( 1.3.6.1.4.1.37505.1.7       NAME 'role'    EQUALITY 
caseIgnoreMatch       SUBSTR caseIgnoreSubstringsMatch       SYNTAX 1.3.6.1.
4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: {6}( 1.3.6.1.4.1.37505.1.8       NAME 'im'       EQUALITY 
caseIgnoreMatch       SUBSTR caseIgnoreSubstringsMatch       SYNTAX 
1.3.6.1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: {7}( 1.3.6.1.4.1.37505.1.9       NAME 'url'      EQUALITY
caseIgnoreMatch       SUBSTR caseIgnoreSubstringsMatch       SYNTAX 
1.3.6.1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: {8}( 1.3.6.1.4.1.37505.1.10       NAME 'otherPhone'   
EQUALITY caseIgnoreMatch       SUBSTR caseIgnoreSubstringsMatch       SYNTAX 
1.3.6.1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: {9}( 1.3.6.1.4.1.37505.1.11       NAME 
'privatePersonalIdentifier'       EQUALITY caseIgnoreMatch       SUBSTR 
caseIgnoreSubstringsMatch  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: {10}( 1.3.6.1.4.1.37505.1.12       NAME 
'profileconfiguration'       EQUALITY caseIgnoreMatch       SUBSTR 
caseIgnoreSubstringsMatch  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: {11}( 1.3.6.1.4.1.37505.1.13       NAME 
'prefferedLanguage'          EQUALITY caseIgnoreMatch       SUBSTR 
caseIgnoreSubstringsMatch  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )

我究竟做錯了什麼?

答案1

我解決了。

olcObjectClasses: 之後的所有內容都需要作為一行讀取,但事實並非如此。這是由於我在 ldif 檔案中分隔行的方式造成的。下面是工作文件。 (在一行前面加一個空格表示該行是前一行的延續)

dn: cn={4}wso2Person,cn=schema,cn=config
changetype: modify
add: olcObjectClasses
olcObjectClasses: ( 0.3.6.1.4.1.37505.1.1
  NAME 'wso2Person'
  DESC 'wso2Person'
  SUP inetOrgPerson
  STRUCTURAL
  MAY ( gender $ country $ nickName $ timeZone $ dateOfBirth $ role $ im $ 
  url $ otherPhone $ privatePersonalIdentifier $ profileconfiguration $ 
  prefferedLanguage))

當我添加方案的其餘部分時沒有讀取它的原因是由於在不適當的位置有額外的換行符。新增的 olcObjectClass 與其餘 LDIF 內容之間有一個空白行。下面。

[..]
olcAttributeTypes: {11}( 1.3.6.1.4.1.37505.1.13       NAME 
'prefferedLanguage'          EQUALITY caseIgnoreMatch       SUBSTR 
caseIgnoreSubstringsMatch  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )

olcObjectClasses: ( 0.3.6.1.4.1.37505.1.1
[...]

相關內容