如何通过脚本添加 Open Directory 服务器?

如何通过脚本添加 Open Directory 服务器?

在全新的映像计算机上通过 shell 脚本添加 Open Directory 服务器的最佳方法是什么?

我已经使用 InstaDMG 创建了一个新图像,并且我想通过 shell 脚本添加 Open Directory Server,而不是使用 Directory Utility 手动执行此操作。

计算机无需绑定开放目录。(客户端:10.5.7,服务器:10.4.11)

答案1

我发现部署图像的方法(Deploy Studio)已经有脚本可以执行 Open Directory 绑定 - 我稍微修改了脚本,给出了脚本的关键部分,以便在这里回答我的问题。此示例仅使用匿名绑定(未明确绑定到 OD 服务器)

#!/bin/sh

# Used ds_open_directory_binding.sh (v1.6) from Deploy Studio as a base for the explicit question.
# I recommend downloading Deploy Studio (http://deploystudio.com) to see other methods but the crux
# of how it is done can be read here. (eg. no error checking here)

#Enable LDAPv3 Plugin
defaults write /Library/Preferences/DirectoryService/DirectoryService "LDAPv3" Active 2>&1
chmod 600 /Library/Preferences/DirectoryService/DirectoryService.plist 2>&1

/usr/sbin/ipconfig waitall

#Configure LDAP
dsconfigldap -a 'server.example.com' 2>&1

#Restart DS
killall DirectoryService
sleep 5

#Create Search Policy
dscl localhost -create /Search SearchPolicy CSPSearchPath 2>&1

#Create Contacts
dscl localhost -create /Contact SearchPolicy CSPSearchPath 2>&1

#Add OD Server to the search path
dscl localhost -append /Search CSPSearchPath '/LDAPv3/server.example.com' 2>&1

#Add OD Server to Contact Search Policy
dscl localhost -append /Contact CSPSearchPath '/LDAPv3/server.example.com' 2>&1

相关内容