LDAP 自动安装映射

可以配置自动安装子系统以从 LDAP 服务器检索其映射。

要在 LDAP 中管理自动安装映射,请在 /etc/irs.conf 文件中添加以下行:
automount nis_ldap

为了在 LDAP 中管理自动安装映射,需要创建相应的 LDIF 文件。 您可以使用 nistoldif 命令将本地自动安装映射文件转换为 LDIF 格式。 例如,如果 LDAP 服务器被命名为ldapserver,那么其基本后缀为 dc=suffix,并且 /etc/auto_home 映射文件包含以下行:

user1		 server1:/home/user1     
user2		 server1:/home/user2     
user3		 server1:/home/user3
使用以下命令为 /etc/auto_home 映射文件创建 LDIF 文件,并将其添加到 LDAP 服务器:
nistoldif -d dc=suffix -sa -f /etc/auto_home > /tmp/auto_home.ldif
ldapadd -D cn=admin -w passwd -h ldapserver -f /tmp/auto_home.ldif
为了从 LDAP 服务器编辑或除去现有的自动安装条目,必须手动创建 LDIF 文件。 例如,如果 user2 的主目录目前在 server2 上,那么应该创建以下 LDIF:
# cat /tmp/ch_user2.ldif
dn: automountKey=user2,automountMapName=auto_home,dc=suffix
changetype: modify
replace: automountInformation
automountInformation: server2:/home/user2
在创建以上 LDIF 之后,运行以下命令:
ldapmodify -D cn=admin -w passwd -h ldapserver -f /tmp/ch_user2.ldif
您还必须创建一个 LDIF 文件来除去用户。 例如,要除去 user3,可创建以下 LDIF:
# cat /tmp/rm_user3.ldif
dn: automountKey=user3,automountMapName=auto_home,dc=suffix
changetype: delete
在创建以上 LDIF 之后,运行以下命令:
ldapmodify -D cn=admin -w passwd -h ldapserver -f /tmp/rm_user3.ldif