3

What is the best method to add an Open Directory server via a shell script on a brandly new imaged computer?

I've created a new image with InstaDMG and I'd like to add the Open Directory Server via a shell script rather than having to do it manually by hand using Directory Utility.

The computer does not have to bind the Open Directory. (Client: 10.5.7, Server: 10.4.11)

Chealion
  • 5,713
  • 27
  • 29
  • +1 great question, but annoying for me! i have the lines you need in a text clipping *somewhere* on my drive. One thing though, could you clarify the last line - it sounds like you *do* want to bind so I don't understand that part. – username May 24 '09 at 21:58
  • @username - I don't particularily care about explicitly binding with a username and password (meaning anonymous binding is fine). – Chealion May 24 '09 at 22:07
  • cool. i'll keep digging around. i'm pretty sure i found the lines in the Apple CLI pdf. seems like an easy question to answer, but when i originally googled i remember finding lots of dross – username May 24 '09 at 22:28

1 Answers1

4

I discovered the method (Deploy Studio) I was deploying my images had scripts already to do the Open Directory binding - I've modified the scripts slightly to give the crux of the script for here to answer my question. This example only uses anonymous binding (not explicitly bound to the OD server)

#!/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
Chealion
  • 5,713
  • 27
  • 29
  • DeployStudio is fantastic, I've just started using it and am very impressed with the workflow layout. – MDMarra Aug 16 '09 at 23:30