LDAP-使用 ldapmodify 添加新的属性模式

LDAP- adding new attribute schema using ldapmodify

我正在尝试向 FreeIPA 添加新架构,我正在按照教程“Extending the FreeIPA Server”进行操作,为了添加新架构,我必须使用 'ldapmodify' 命令。但我得到了这个结果:

[root@rnddomain schema]# ldapmodify -D "cn=admin" -W -f favorateColorName.ldif
Enter LDAP Password: 
ldap_bind: No such object (32)

我知道很多人已经问过这个话题,但他们的回答都没有解决我的问题。这是我要添加的模式:

dn: cn=schema
changetype: modify
add: attributeTypes
attributeTypes: ( 2.25.28639311321113238241701611583088740684.14.2.2
  NAME 'favoriteColorName'
  EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch
  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
  X-ORIGIN 'Extending FreeIPA' )

我从远方说起

绑定到LDAP 时,需要指定一个绑定DN。虽然 Active Directory 允许指定 rdn 而不是完整的 DN(例如 cn=Administrator),但其他 LDAP 服务器不一定允许这样做。此外,RDN 可能不是 cn。在 FreeIPA 中使用了 uid 属性——而不是使用 cn=admin 你需要指定完整的 DN,它应该是 uid=admin,cn=users,cn=accounts,dc=example,dc=com。您始终可以通过 ipa user-find --raw --all --pkey-only <user>:

获取用户的 DN
$ ipa user-find --raw --all --pkey-only admin
--------------
1 user matched
--------------
  dn: uid=admin,cn=users,cn=accounts,dc=example,dc=com
  uid: admin
----------------------------
Number of entries returned 1
----------------------------

但是,知道管理员的完整 DN 不会帮助您进行架构更新。 FreeIPA 的 LDAP 服务器在内部使用访问控制来防止目录管理员以外的任何人修改模式。目录管理器是一个具有完整 DN cn=Directory Manager 的特殊帐户,因此您应该使用它来导入架构更新。

但我建议您不要使用直接 ldapmodify 进行架构分发。 FreeIPA 有一个名为 ipa-ldap-updater 的工具,它提供了一种分发此类更新的好方法——不仅是架构,还可以添加新条目和修改现有条目。您可以在我的博客文章 here.

中查看有关如何添加新条目或修改配置的详细信息

为模式文件创建一个名为 NNname.ldif 的文件,其中 NN 是一个介于 00 和 90 之间的数字,并将其放置在某处。 FreeIPA 对模式文件使用 /usr/share/ipa/,对股票更新文件使用 /usr/share/ipa/updates,您也可以了解那里的情况。然后 运行 ipa-ldap-updater --schema-file NNname.ldif 它将安装您的模式。有关其他详细信息,请参阅 ipa-ldap-updater 的手册页。

模式的 ipa-ldap-updater 语法遵循 389-ds 模式文件,因此您的模式定义如下所示:

dn: cn=schema
attributeTypes: ( 2.25.28639311321113238241701611583088740684.14.2.2
 NAME 'favoriteColorName'
 EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch
 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
 X-ORIGIN 'Extending FreeIPA' )

attributeTypes 或 objectClasses 值应遵循标准 LDIF 格式语法——如果您想将单个值拆分为多行,续行必须以 space 开头(如上)。