系统管理指南:名称和目录服务(DNS、NIS 和 LDAP)

第 11 章 为使用 LDAP 客户机设置 Sun Java System Directory Server(任务)

本章介绍如何配置 Sun Java System Directory Server(以前称为 Sun ONE Directory Server),使其支持 Solaris LDAP 名称服务客户机网络。本章中的信息特定于 Sun Java System Directory Server。 有关安装和配置目录服务器的信息,请参见 Sun Java Enterprise System 附带的 Sun Java System Directory Server 文档。


注意 –

必须先执行 Sun Java System Directory Server 随附的安装和配置文档中介绍的所有步骤,才能配置 Sun Java System Directory Server,使其与 Solaris LDAP 客户机协作。



注意 –

目录服务器(LDAP 服务器)不能作为其自身的客户机。


本章包含以下主题:

使用 idsconfig 配置 Sun Java System Directory Server

基于服务器安装创建核对表

在服务器的安装过程中,将会完成一些重要变量的定义,在启动 idsconfig 之前,会使用这些变量创建类似如下的核对表。可以使用空白核对表中提供的空白核对表。


注意 –

下面列出的信息将作为与 LDAP 有关的各章中介绍的所有示例的基础。示例域是一个名为 Example, Inc. 的装饰品公司,该公司的商店遍布全美。示例涉及到西海岸分公司,它的域是 west.example.com


表 11–1 定义的服务器变量

变量 

为示例网络定义的变量 

用于安装目录服务器实例的端口号 

389(缺省值) 

服务器名称  

myserver (来自 FQDN myserver.west.example.com 或 192.168.0.1)

副本服务器(IP 号:端口号) 

192.168.0.2 [对于 myreplica.west.example.com]

目录管理器 

cn=Directory Manager(缺省值) 

要为其提供服务的域名  

west.example.com

在超时之前处理客户端请求的最长时间(以秒为单位) 

-1

为每个搜索请求返回的最多项数 

-1


注意 –

如果要使用主机名来定义 defaultServerListpreferredServerList,则必须确保不使用 LDAP 进行主机查找。 这意味着 ldap 不得位于 /etc/nsswitch.conf hosts 行中。


表 11–2 定义的客户机配置文件变量

变量 

为示例网络定义的变量 

配置文件名(缺省名称是 "default")。 

WestUserProfile

服务器列表(缺省值为本地子网) 

192.168.0.1

首选服务器列表(按照对服务器进行查找的顺序列出) 

none

搜索范围(沿着目录树向下查找的层数:"One"(缺省值)或 "Sub")

one(缺省值)

用于获取服务器访问权限的凭证。缺省值为 anonymous

proxy

是否遵循 引用(在主服务器不可用时,指针是否指向另一台服务器)?缺省值为 no

Y

等待服务器返回信息的搜索时间限制(缺省值为 30 秒)。 

default

与服务器进行联系时的绑定时间限制(缺省值为 10 秒)。 

default

验证方法(缺省值为 none)。

simple


注意 –

针对每个域都定义了一个客户机配置文件。必须为给定的域至少定义一个配置文件。


属性索引

idsconfig 为下面列出的 属性编制索引以改善性能。

membernisnetgroup

pres,eq,sub

nisnetgrouptriple

pres,eq,sub

ipHostNumber

pres,eq,sub

uidNumber

pres,eq

gidNumber

pres,eq

ipNetworkNumber

pres,eq

automountkey

pres,eq

oncRpcNumber

pres,eq

架构定义

idsconfig(1M) 会自动添加必要的架构定义。除非您在 LDAP 管理方面经验丰富,否则请不要手动修改服务器架构。有关 LDAP 名称服务所用架构的扩展列表,请参见第 14 章,LDAP 一般参考(参考)

使用浏览索引

使用 Sun Java System Directory Server 的浏览索引 功能(又称为虚拟列表视图 (virtual list view, VLV)),客户机可以从非常长的列表中查看一组或许多选定的项,从而缩短每台客户机的搜索时间。浏览索引提供经过优化的预定义搜索参数,使用这些参数,Solaris LDAP 名称客户机可以更快地从各个服务访问特定信息。请记住,如果您未创建浏览索引,客户机可能无法获得给定类型的全部项,因为在服务器上可能实施了搜索时间或项数限制。

VLV 索引是在目录服务器上配置的,代理用户对这些索引具有读取访问权限。

在 Sun Java System Directory Server 上配置浏览索引之前,请考虑与使用这些索引相关联的性能成本。有关更多信息,请参阅所用 Sun Java System Directory Server 版本的管理指南

idsconfig 会为多个 VLV 索引创建相应的项。可以使用 directoryserver 脚本来停止服务器并创建实际的 VLV 索引。有关更多信息,请参见 idsconfig(1M)directoryserver(1M) 手册页。请参阅 idsconfig 命令的输出以确定由 idsconfig 创建的 VLV 项以及需要运行的相应 directoryserver 命令的语法。请参见 idsconfig 设置示例了解样例 idsconfig 输出。

使用服务搜索描述符来修改客户机对各个服务的访问

服务 搜索描述符 (service search descriptor, SSD) 会将 LDAP 中给定操作的缺省搜索请求更改为您定义的搜索。 例如,如果一直在使用具有自定义容器定义的 LDAP 或其他操作系统,而且现在要转为使用最新的 Solaris 发行版,则 SSD 特别有用。使用 SSD,可以在不必更改现有 LDAP 数据库和数据的情况下配置 Solaris LDAP 名称服务。

使用 idsconfig 设置 SSD

在 Example, Inc. 中,假设前任管理员已经配置了 LDAP,并将用户存储在 ou=Users 容器中。现在要升级到最新的 Solaris 发行版。按照定义,Solaris LDAP 客户机假设用户项存储在 ou=People 容器中。因此,当开始搜索 passwd 服务时,LDAP 客户机将搜索 DIT ou=people 层,因而不会找到正确的值。

对于上述问题,一个比较麻烦的解决方案就是完全覆写 Example, Inc. 现有的 DIT,并重写 Example, Inc. 网络上现有的所有应用程序,以便它们与新的 LDAP 名称服务兼容。另外一种更可取的解决方案就是,使用 SSD 来通知 LDAP 客户机在 ou=Users 容器(而不是缺省的 ou=people 容器)中查找用户信息。

在使用 idsconfig 配置 Sun Java System Directory Server 的过程中将需要定义必要的 SSD。提示行如下所示:


Do you wish to setup Service Search Descriptors (y/n/h? y

  A  Add a Service Search Descriptor

  D  Delete a SSD

  M  Modify a SSD

  P  Display all SSD's

  H  Help

  X  Clear all SSD's



  Q  Exit menu

Enter menu choice: [Quit] a

Enter the service id: passwd

Enter the base: service ou=user,dc=west,dc=example,dc=com

Enter the scope: one[default]

  A  Add a Service Search Descriptor

  D  Delete a SSD

  M  Modify a SSD

  P  Display all SSD's

  H  Help

  X  Clear all SSD's



  Q  Exit menu

Enter menu choice: [Quit] p



Current Service Search Descriptors:

==================================

Passwd:ou=Users,ou=west,ou=example,ou=com?



Hit return to continue.



  A  Add a Service Search Descriptor

  D  Delete a SSD

  M  Modify a SSD

  P  Display all SSD's

  H  Help

  X  Clear all SSD's



  Q  Exit menu

Enter menu choice: [Quit] q

运行 idsconfig


注意 –

运行 idsconfig 无需特殊权限,也不必在 LDAP 命名客户机上运行。请记住按照基于服务器安装创建核对表中的说明创建一个核对表以准备运行 idsconfig。不必从服务器或 LDAP 名称服务客户机运行 idsconfig。可以从网络上的任何 Solaris 计算机运行 idsconfig



注意 – 注意 –

idsconfig 以明文形式发送目录管理器的口令。如果不希望出现这种情况,则必须在目录服务器(而非客户机)上运行 idsconfig


如何使用 idsconfig 来配置 Sun Java System Directory Server
  1. 确保目标 Sun Java System Directory Server 已打开且正在运行。

  2. 运行 idsconfig


    # /usr/lib/ldap/idsconfig
    

    有关使用服务器和客户机核对表中列出的定义运行 idsconfig 的示例,请参阅实例 11–1,这些核对表位于本章开头处的基于服务器安装创建核对表中。

  3. 根据提示回答问题。

    请注意 "no" [n] 是缺省的用户输入。如果需要弄清楚任何给定的问题,请键入


    h
    
    此时将出现一个简短的帮助段落。

    idsconfig 完成了目录的设置之后,您需要在服务器上运行指定的命令,才能完成服务器的设置过程,服务器此时即可为客户机提供服务。

idsconfig 设置示例

本节提供了一个简单的 idsconfig 设置示例,该示例没有对缺省值进行太多修改。修改客户机配置文件最复杂的方法就是创建 SSD。有关详细讨论,请参阅使用服务搜索描述符来修改客户机对各个服务的访问

提示符后面的回车符表示可通过按 Enter 来接受 [缺省值]。


注意 –

对于摘要屏幕上留空的任何参数将不进行设置。


idsconfig 完成了目录的设置之后,您需要在服务器上运行指定的命令,才能完成服务器的设置过程,服务器此时即可为客户机提供服务。


实例 11–1 对于 Example, Inc. 网络运行 idsconfig


# usr/lib/ldap/idsconfig

It is strongly recommended that you BACKUP the directory server

before running idsconfig.



Hit Ctrl-C at any time before the final confirmation to exit.



Do you wish to continue with server setup (y/n/h)? [n] Y

Enter the directory server's hostname to setup: myserver

Enter the Directory Server's port number (h=help): [389]

Enter the directory manager DN: [cn=Directory Manager] 

Enter passwd for cn=Directory Manager : 

Enter the domainname to be served (h=help): [west.example.com] 

Enter LDAP Base DN (h=help): [dc=west,dc=example,dc=com] 

Enter the profile name (h=help): [default] WestUserProfile

Default server list (h=help): [192.168.0.1] 

Preferred server list (h=help): 

Choose desired search scope (one, sub, h=help):  [one] 

The following are the supported credential levels:

  1  anonymous

  2  proxy

  3  proxy anonymous

Choose Credential level [h=help]: [1] 2

The following are the supported Authentication Methods:

  1  none

  2  simple

  3  sasl/DIGEST-MD5

  4  tls:simple

  5  tls:sasl/DIGEST-MD5

Choose Authentication Method (h=help): [1] 2

Current authenticationMethod: simple



Do you want to add another Authentication Method? N

Do you want the clients to follow referrals (y/n/h)? [n] N

Do you want to modify the server timelimit value (y/n/h)? [n] Y

Enter the server time limit (current=3600): [-1]

Do you want to modify the server sizelimit value (y/n/h)? [n] Y

Enter the server size limit (current=2000): [-1]

Do you want to store passwords in "crypt" format (y/n/h)? [n] Y

Do you want to setup a Service Authentication Methods (y/n/h)? [n]

Client search time limit in seconds (h=help): [30] 

Profile Time To Live in seconds (h=help): [43200] 

Bind time limit in seconds (h=help): [10]

Do you wish to setup Service Search Descriptors (y/n/h)? [n] 

 

              Summary of Configuration



  1  Domain to serve               : west.example.com

  2  Base DN to setup              : dc=west,dc=example,dc=com

  3  Profile name to create        : WestUserProfile

  4  Default Server List           : 192.168.0.1

  5  Preferred Server List         : 

  6  Default Search Scope          : one

  7  Credential Level              : proxy

  8  Authentication Method         : simple

  9  Enable Follow Referrals       : FALSE

 10  Server Time Limit             : -1

 11  Server Size Limit             : -1

 12  Enable crypt password storage : TRUE

 13  Service Auth Method pam_ldap  : 

 14  Service Auth Method keyserv   : 

 15  Service Auth Method passwd-cmd: 

 16  Search Time Limit             : 30

 17  Profile Time to Live          : 43200

 18  Bind Limit                    : 10

 19  Service Search Descriptors Menu



Enter config value to change: (1-19 0=commit changes) [0] 

Enter DN for proxy agent:[cn=proxyagent,ou=profile,dc=west,dc=example,dc=com]

Enter passwd for proxyagent: 

Re-enter passwd: 

 

WARNING: About to start committing changes. (y=continue, n=EXIT) Y

1. Changed timelimit to -1 in cn=config.

2. Changed sizelimit to -1 in cn=config.

3. Changed passwordstoragescheme to "crypt" in cn=config.

4. Schema attributes have been updated.

5. Schema objectclass definitions have been added.

6. Created DN component dc=west.

7. NisDomainObject added to dc=west,dc=example,dc=com.

8. Top level "ou" containers complete.

9. automount maps: auto_home auto_direct auto_master auto_shared processed.

10. ACI for dc=west,dc=example,dc=com modified to disable self modify.

11. Add of VLV Access Control Information (ACI).

12. Proxy Agent cn=proxyagent,ou=profile,dc=west,dc=example,dc=com added.

13. Give cn=proxyagent,ou=profile,dc=west,dc=example,dc=com read permission for 

password.

14. Generated client profile and loaded on server.

15. Processing eq,pres indexes:

      uidNumber (eq,pres)   Finished indexing.

      ipNetworkNumber (eq,pres)   Finished indexing.

      gidnumber (eq,pres)   Finished indexing.

      oncrpcnumber (eq,pres)   Finished indexing.

      automountKey (eq,pres)   Finished indexing.

16. Processing eq,pres,sub indexes:

      ipHostNumber (eq,pres,sub)   Finished indexing.

      membernisnetgroup (eq,pres,sub)   Finished indexing.

      nisnetgrouptriple (eq,pres,sub)   Finished indexing.

17. Processing VLV indexes:

      west.example.com.getgrent vlv_index     Entry created

      west.example.com.gethostent vlv_index   Entry created

      west.example.com.getnetent vlv_index    Entry created

      west.example.com.getpwent vlv_index     Entry created

      west.example.com.getrpcent vlv_index    Entry created

      west.example.com.getspent vlv_index     Entry created

      west.example.com.getauhoent vlv_index   Entry created

      west.example.com.getsoluent vlv_index   Entry created

      west.example.com.getauduent vlv_index   Entry created

      west.example.com.getauthent vlv_index   Entry created

      west.example.com.getexecent vlv_index   Entry created

      west.example.com.getprofent vlv_index   Entry created

      west.example.com.getmailent vlv_index   Entry created

      west.example.com.getbootent vlv_index   Entry created

      west.example.com.getethent vlv_index    Entry created

      west.example.com.getngrpent vlv_index   Entry created

      west.example.com.getipnent vlv_index    Entry created

      west.example.com.getmaskent vlv_index   Entry created

      west.example.com.getprent vlv_index     Entry created

      west.example.com.getip4ent vlv_index    Entry created

      west.example.com.getip6ent vlv_index    Entry created



idsconfig: Setup of myserver is complete.



Note: idsconfig has created entries for VLV indexes.  Use the

      directoryserver(1m) script on myserver to stop

      the server and then enter the following vlvindex

      sub-commands to create the actual VLV indexes:



  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getgrent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.gethostent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getnetent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getpwent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getrpcent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getspent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getauhoent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getsoluent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getauduent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getauthent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getexecent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getprofent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getmailent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getbootent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getethent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getngrpent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getipnent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getmaskent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getprent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getip4ent

  directoryserver -s myserver vlvindex -n userRoot -T west.example.com.getip6ent

使用 ldapaddent 填充目录服务器


注意 –

在用数据填充目录服务器之前, 必须配置服务器,使其在您使用 pam_unix 时,以 UNIX Crypt 格式存储口令。如果您使用的是 pam_ldap,则可以用任何格式存储口令。有关以 UNIX crypt 格式设置口令的更多信息,请参见 Sun Java System Directory Server 文档。


ldapaddent 从标准输入(类似于 passwd/etc/filename)读取数据并将其放到与该服务相关联的容器中。客户机的配置确定了数据的缺省写入方式。


注意 –

ldapaddent(1M) 只能在 LDAP 客户机上运行。第 12 章,设置 LDAP 客户机(任务)介绍了如何为 LDAP 名称服务配置客户机。


如何通过 ldapaddent 来向 Sun Java System Directory Server 填充用户口令数据

请参见ldapaddent(1M)。有关 LDAP 安全性和对目录服务器写入访问权限的信息,请参见第 9 章,LDAP 的基本组件和概念(概述)

  1. 可以使用 ldapaddent 命令来向服务器中添加 /etc/passwd 项。


    # ldapaddent -D "cn=directory manager" -f /etc/passwd passwd
    

管理打印机项

添加打印机

要向 LDAP 目录中添加打印机项,请使用 printmgr 配置工具或 lpset -n ldap 命令行实用程序。请参见lpset(1M)。请注意,添加到该目录中的打印机对象仅定义了打印系统客户机所需的打印机连接参数。本地打印服务器配置数据仍保留在文件中。典型的打印机项将如下所示:


printer-uri=myprinter,ou=printers,dc=mkg,dc=example,dc=com

objectclass=top

objectclass=printerService

objectclass=printerAbstract

objectclass=sunPrinter

printer-name=myprinter

sun-printer-bsdaddr=printsvr.example.com,myprinter,Solaris

sun-printer-kvp=description=HP LaserJet (PS)

printer-uri=myprinter

使用 lpget

lpget(1M) 可用于列出 LDAP 客户机的 LDAP 目录已知的所有打印机项。如果 LDAP 客户机的 LDAP 服务器是副本服务器,则列出的打印机可能不同于主 LDAP 服务器中的打印机,具体情况取决于更新复制协议。有关更多信息,请参见lpget(1M)

例如,要列出给定基 DN 的所有打印机,请键入以下内容:


# lpget -n ldap list

myprinter:

	dn=myprinter,ou=printers,dc=mkt,dc=example,dc=com

	bsdaddr=printsvr.example.com,myprinter,Solaris

	description=HP LaserJet (PS)

向目录服务器填充其他配置文件

使用带有 genprofile 选项的 ldapclient,可以基于所指定的属性,针对配置创建 LDIF 表示形式的配置文件。随后可以将所创建的配置文件加载到要用作客户机配置文件的 LDAP 服务器中。客户机可以使用 ldapclient init 来下载客户机配置文件。

有关使用 ldapclient genprofile 的信息,请参阅 ldapclient(1M)

如何通过 ldapclient 来向目录服务器填充其他配置文件
  1. 成为超级用户或承担等效角色。

    角色包含授权和具有一定权限的命令。有关角色的更多信息,请参见 System Administration Guide: Security Services中的“Using Role-Based Access Control (Tasks)”

  2. 使用带 genprofileldapclient 命令。


    # ldapclient genprofile \
    
    -a profileName=myprofile \
    
    -a defaultSearchBase=dc=west,dc=example,dc=com \
    
    -a "defaultServerList=192.168.0.1 192.168.0.2:386" \
    

    > myprofile.ldif

  3. 将新配置文件上载到服务器上。


    # ldapadd -h 192.168.0.1 -D “cn=directory manager” -f myprofile.ldif
    

配置目录服务器以启用帐户管理

为了让 pam_ldap 能够正确工作,必须在服务器上正确配置口令和帐户锁定策略。可以使用 Directory Server Console 或 ldapmodify 来为 LDAP 目录配置帐户管理策略。有关配置过程和更多信息,请参见所用 Sun Java System Directory Server 版本的管理指南中的“用户帐户管理”一章。


注意 –

启用 pam_ldap 帐户管理后,所有用户在每次登录系统时都必须提供口令。进行验证时必须提供登录口令。因此,使用 rshrloginssh 等工具进行的不基于口令的登录将会失败。


绝不应当允许 proxy 用户的口令过期。 如果代理口令过期,使用 proxy 凭证级别的客户机将无法从服务器检索名称服务信息。为了确保代理用户的口令不过期,请使用以下脚本修改代理帐户:


# ldapmodify -h ldapserver -D administrator DN \

-w  administrator password <<EOF 

dn: proxy user DN

DNchangetype: modify

replace: passwordexpirationtime

passwordexpirationtime: 20380119031407Z

EOF

注意 –

pam_ldap 帐户管理依赖 Sun Java System Directory Server 来为用户维护和提供口令失效和帐户过期信息。目录服务器在验证用户帐户时不解释阴影项中的相应数据。但是,pam_unix 会检查阴影数据以确定帐户是否处于锁定状态或者口令是否已失效。由于 LDAP 名称服务或目录服务器不会使阴影数据保持最新,因此 pam_unix 不应当基于阴影数据授予访问权限。阴影数据是使用 proxy 标识检索的。 因此,请不要允许 proxy 用户对 userPassword 属性具有读取访问权限。拒绝 proxy 用户对 userPassword 的读取访问权限可防止 pam_unix 进行无效的帐户验证。


迁移 Sun Java System Directory Server

在 Sun Java System Directory Server 5.1 发行版(以前称为 Sun ONE Directory Server)和 Sun Java System Directory Server 5.2 发行版之间实现了架构更改。ldapaddent 命令现在向 ethers/bootparams 的项中添加了 objectclass: device。因此,如果您选择使用 LDAP 命令将目录数据从 Sun Java System Directory Server 5.1 迁移到 5.2,则必须使用 ldapaddent -d 导出数据,并使用 ldapaddent 导入数据。否则,如果使用 Sun Java System Directory Server 工具(db2ldifldif2db)来迁移数据,则必须在迁移数据之前向 Sun Java System Directory Server 5.2 应用所有的修补程序,否则数据导入操作将失败。

有关配置 Sun Java System Directory Server 5.2 的信息,请参见 Sun Java Enterprise System 附带的 Sun Java System Directory Server 文档。