Mac-Osx

如何通過腳本添加 Open Directory 伺服器?

  • May 24, 2009

在全新的映像電腦上通過 shell 腳本添加 Open Directory 伺服器的最佳方法是什麼?

我用 InstaDMG 創建了一個新圖像,我想通過 shell 腳本添加 Open Directory Server,而不是使用 Directory Utility 手動完成。

電腦不必綁定 Open Directory。(客戶端:10.5.7,伺服器:10.4.11)

我發現我正在部署我的圖像的方法(部署工作室)已經有腳本來執行 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

引用自:https://serverfault.com/questions/11042