Shell Script to remove a client's bindings to an old server and then bind them to a new Directory server.

This is a script that will remove the current binding of the client machine and then rebind it to whatever Directory Server you specify.  It works in 10.4.11 and 10.5.


#!/bin/sh
#This script binds a 10.4.11 or 10.5 client to an LDAP (OD) server.

oldserver="old.domain.com"
newserver="new.domain.com"

/usr/sbin/dsconfigldap -r $oldserver
/usr/bin/dscl localhost -delete /Search CSPSearchPath /LDAPv3/$oldserver
/usr/bin/dscl localhost -delete /Contact CSPSearchPath /LDAPv3/$oldserver
sleep 10 #give it time to clear before proceeding
/usr/sbin/dsconfigldap -a $newserver
/usr/bin/dscl localhost -create /Search SearchPolicy dsAttrTypeStandard:CSPSearchPath
/usr/bin/dscl localhost -merge /Search CSPSearchPath /LDAPv3/$newserver
/usr/bin/dscl localhost -create /Contact SearchPolicy dsAttrTypeStandard:CSPSearchPath
/usr/bin/dscl localhost -merge /Contact CSPSearchPath /LDAPv3/$newserver
Your rating: None Average: 4 (2 votes)