OpenLDAP sAMAccountName 作为自定义属性

OpenLDAP sAMAccountName as custom attribute

我正在尝试添加自定义属性对象 class,因为我的一个应用程序仅适用于 sAMAccountName。

我发现它需要以下架构才能将其添加到 LDAP。

olcAttributeTypes: ( 1.2.840.113556.1.4.221
NAME 'sAMAccountName'
SYNTAX '1.3.6.1.4.1.1466.115.121.1.15'
SINGLE-VALUE )

我用这个内容创建了一个 ldif 文件,并且 sAMAccountName 出现在 Apache Directory Studio 中

dn: cn=custom-attributes,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: custom-attributes
olcAttributeTypes: ( 1.2.840.113556.1.4.221
    NAME 'sAMAccountName'
    SYNTAX '1.3.6.1.4.1.1466.115.121.1.15'
    SINGLE-VALUE )

但是如果我尝试将此属性添加到我的用户,我会收到错误 #65,因为我的对象 classes 不允许它,所以我将其删除并尝试添加一个对象 class 对于自定义属性:

dn: cn=custom-attributes,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: custom-attributes
olcAttributeTypes: ( 1.2.840.113556.1.4.221
    NAME 'sAMAccountName'
    SYNTAX '1.3.6.1.4.1.1466.115.121.1.15'
    SINGLE-VALUE )
olcObjectClasses: ( 1.3.6.1.4.1.4203.666.100.1
    NAME 'customAttributes'
    SUP top
    AUXILIARY
    DESC 'Custom attributes class'
    MAY (sAMAccountName)
)

现在我收到这个错误

ldapadd: invalid format (line 6) entry: "cn=custom-attributes,cn=schema,cn=config"

我正在通过终端添加 ldif 文件

ldapadd -H ldaps://ldap.mydomain.com/ -f samaccountname.ldif -D "cn=admin,cn=config" -w mypassword

错误信息指的是哪一行?语法有什么问题?

我也听说过将 sAMAccountName 代理到 uid,但我没有找到示例 ldif 文件,所以这个解决方案对我来说更容易实现。

我认为这是由于最后一个括号。 LDIF 文件上的新行意味着新的项目描述。尝试将最后一个括号放在 MAY 行的末尾。