OpenLDAP 無法新增屬性

OpenLDAP 無法新增屬性

我想建立一些具有「性別」等屬性的使用者帳戶,這意味著我需要建立自訂屬性。

我建立了以下 LDIF 檔案:

dn: cn=schema
changetype: modify
add: attributeTypes
attributeTypes: ( 1.2.3.4.5.6.7.8.9.0 NAME ( 'gender' ) DESC 'gender' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )

並嘗試將其應用到ldapmodify -D cn=admin,cn=config -W -f ExtendedUser.ldif.

但我總是收到這個錯誤:

modifying entry "cn=schema"
ldap_modify: Invalid syntax (21)
        additional info: attributeTypes: value #0 invalid per syntax

我知道我還需要一個物件類別來使用該屬性,我最初嘗試使用物件類別定義和包含的其他屬性(見下文),但這導致了相同的錯誤。

舊的、更詳細的 LDIF:

dn: cn=schema
changetype: modify
add: attributeTypes
attributeTypes: ( 1.2.3.4.5.6.7.8.9.0 NAME 'gender' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
attributeTypes: ( 1.2.3.4.5.6.7.8.9.1 NAME 'birthdate' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
attributeTypes: ( 1.2.3.4.5.6.7.8.9.2 NAME 'birthplace' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
attributeTypes: ( 1.2.3.4.5.6.7.8.9.3 NAME 'nationality' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
attributeTypes: ( 1.2.3.4.5.6.7.8.9.4 NAME 'street' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
attributeTypes: ( 1.2.3.4.5.6.7.8.9.5 NAME 'zipcode' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
attributeTypes: ( 1.2.3.4.5.6.7.8.9.6 NAME 'city' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
attributeTypes: ( 1.2.3.4.5.6.7.8.9.7 NAME 'phone' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
attributeTypes: ( 1.2.3.4.5.6.7.8.9.8 NAME 'matnr' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )

dn: cn=schema
changetype: modify
add: objectClasses
objectClasses: ( 4.5.6.7.8.9.2 NAME 'AdditionalAttrPerson' DESC 'adds user attributes' SUP inetOrgPerson STRUCTURAL MUST ( gender $ birthdate $ birthplace $ nationality $ street $ zipcode $ city $ phone $ matnr ) )

我不知道我做錯了什麼,因為我從教程中複製了語法並且它似乎匹配。請幫忙。

我嘗試在激活調試級別的情況下進行 ldapmodify,輸出似乎沒有用,但這是尾部,出現錯誤:

...
ldap_do_free_request: asked to free lr 0x561b24af5cb0 msgid 2 refcnt 0
ldap_parse_result
ber_scanf fmt ({iAA) ber:
ber_scanf fmt (}) ber:
ldap_msgfree
ldap_err2string
ldap_modify: Invalid syntax (21)
        additional info: attributeTypes: value #0 invalid per syntax

ldap_free_connection 1 1
ldap_send_unbind
ber_flush2: 7 bytes to sd 4
ldap_free_connection: actually freed

上面的內容看起來確實與我無關。

答案1

我應該一開始就查看架構中的其他 LDIF 文件,但這是我的解決方案:

第一行需要是dn cn=myschema,cn=schema,cn=config

之後的那些應該在左側有 olcAttributeTypes 或 olcObjectClasses ,而不是我所擁有的。例子:

dn: cn=myschema,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: myschema
olcAttributeTypes: ( 1.3.6.1.4.1.995.1.2.1 NAME 'gender'
 EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} SINGLE-VALUE )

相關內容