Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)

share|improve this question
    
+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
add comment

1 Answer

up vote 3 down vote accepted

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
share|improve this answer
    
DeployStudio is fantastic, I've just started using it and am very impressed with the workflow layout. –  MDMarra Aug 16 '09 at 23:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.