B.4. 使用 LDIF 指定目录条目


许多类型的条目可以存储在 目录中。本节重点介绍目录中最常用的条目类型:domain、organizational unit 和 organizational person 条目。
为条目定义的对象类是指示条目代表域或域组件、组织单元、组织人员或某些其他类型的条目。有关可在目录中默认使用的对象类的完整列表,以及最常用的属性的列表,请参阅 Red Hat Directory Server 11 Configuration、Command 和 File Reference

B.4.1. 指定域条目

目录通常至少有一个域条目。通常,这是 目录中的第一个或最顶层条目。域条目通常对应于您目录的 DNS 主机和域名。例如,如果目录服务器主机名为 ldap.example.com,则该目录的域条目可能命名为 dc=ldap,dc=example,dc=com,或者只是 dc=example,dc=com
用于定义域的 LDIF 条目如下所示:
dn: distinguished_name 
objectClass: top
objectClass: domain
dc: domain_component_name
 list_of_optional_attributes 
...
Copy to Clipboard Toggle word wrap
以下是 LDIF 格式的域条目示例:
dn: dc=example,dc=com
objectclass: top
objectclass: domain
dc: example
description: Fictional example company
Copy to Clipboard Toggle word wrap
LDIF 格式的域条目的每个元素在 表 B.2 “域条目中的 LDIF 元素” 中定义。
Expand
表 B.2. 域条目中的 LDIF 元素
LDIF 元素 描述
dn: distinguished_name 必需。指定条目的可分辨名称。
swig: top 必需。指定 顶层 对象类。
swig: domain 指定 对象类。此行将条目定义为域或域组件。有关可用于此对象类的属性列表,请参阅 Red Hat Directory Server 11 Configuration、Command 和 File Reference。-->
dc: domain_component 指定域名的属性。服务器通常配置在初始设置期间,具有后缀或命名上下文,格式为 dc=hostname,dc=domain,dc=toplevel。例如,dc=ldap,dc=example,dc=com。域条目应使用最左边的 dc 值,如 dc: ldap。如果后缀为 dc=example,dc=comdc 值为 dc: example。不要为 dn: dc=com 创建条目,除非服务器已配置为使用该后缀。
list_of_attributes 指定要为条目维护的可选属性列表。有关可用于此对象类的属性列表,请参阅 Red Hat Directory Server 11 Configuration、Command 和 File Reference

B.4.2. 指定机构单元条目

组织单元条目通常用于代表目录树中的主要分支点或子目录。它们与企业中的主要、合理的静态实体对应,如包含人员或包含组的子树的子树。
条目中包含的组织单元属性也可能代表公司内的主要组织,如市场营销或工程。但是,不建议采用这种风格。红帽强烈建议使用扁平目录树。
目录树中通常有多个组织单元或分支点。
定义机构单元条目的 LDIF 必须如下所示:
dn: distinguished_name 
objectClass: top
objectClass: organizationalUnit
ou: organizational_unit_name
 list_of_optional_attributes 
...
Copy to Clipboard Toggle word wrap
以下是 LDIF 格式的机构单元条目示例:
dn: ou=people,dc=example,dc=com
objectclass: top
objectclass: organizationalUnit
ou: people
description: Fictional example organizational unit
Copy to Clipboard Toggle word wrap
表 B.3 “机构单元条目中的 LDIF 元素” 定义 LDIF 格式的机构单元条目的每个元素。
Expand
表 B.3. 机构单元条目中的 LDIF 元素
LDIF 元素 描述
dn: distinguished_name 指定条目的可分辨名称。需要 DN。如果 DN 中有一个逗号,逗号必须用反斜杠(\)进行转义,如 dn: ou=people,dc=example,dc=com
swig: top 必需。指定 顶层 对象类。
swig: organizationalUnit 指定 organizationalUnit 对象类。此行将条目定义为 组织单元。有关此对象类可用属性的列表,请参阅 Red Hat Directory Server 11 Configuration、Command 和 File Reference
ou: organizational_unit_name 指定机构单元名称的属性。
list_of_attributes 指定要为条目维护的可选属性列表。有关此对象类可用属性的列表,请参阅 Red Hat Directory Server 11 Configuration、Command 和 File Reference

B.4.3. 指定机构角色条目

目录中的大多数条目都代表机构人员。
在 LDIF 中,机构人员的定义如下:
dn: distinguished_name 
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
cn: common_name 
sn: surname
 list_of_optional_attributes
Copy to Clipboard Toggle word wrap
以下是 LDIF 格式的机构人员条目示例:
dn: uid=bjensen,ou=people,dc=example,dc=com
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Babs Jensen
sn: Jensen
givenname: Babs
uid: bjensen
ou: people
description: Fictional example person
telephoneNumber: 555-5557
userPassword: {SSHA}dkfljlk34r2kljdsfk9
Copy to Clipboard Toggle word wrap
表 B.4 “Person Entries 中的 LDIF 元素” 定义 LDIF person 条目的每个方面。
Expand
表 B.4. Person Entries 中的 LDIF 元素
LDIF 元素 描述
dn: distinguished_name 必需。指定条目的可分辨名称。例如,dn: uid=bjensen,ou=body,dc=example,dc=com。如果 DN 中有一个逗号,则必须使用反斜杠(\)转义逗号。
objectClass: top 必需。指定 顶级 对象类。
objectClass: person 指定 person 对象类。应包含此对象类规格,因为许多 LDAP 客户端在搜索个人或机构人员时需要它。
objectClass: organizationalPerson 指定 organizationalPerson 对象类。应包含此对象类规格,因为有些 LDAP 客户端在搜索机构人员期间需要它。
objectClass: inetOrgPerson 指定 inetOrgPerson 对象类。建议 inetOrgPerson 对象类创建机构人员条目,因为此对象类包含广泛的属性范围。此对象类需要 uid 属性,并且包含此对象类的条目会根据 uid 属性的值命名。有关此对象类可用属性的列表,请参阅 Red Hat Directory Server 11 Configuration, Command, and File Reference
cn: common_name 指定个人的通用名称,这是个人常用的全名。例如: cn: Bill Anderson。至少需要一个通用名称。
sn: surname 指定个人的姓氏或姓氏。例如,s n: Anderson。需要 surname。
list_of_attributes 指定要为该条目维护的可选属性列表。有关此对象类可用属性的列表,请参阅 Red Hat Directory Server 11 Configuration, Command, and File Reference
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat