Script ADunbind.sh killall directoryservice process not found

tcandela
Valued Contributor II

does anyone use the adunbind.sh Script that is provided in the Scripts section of JAMF nation?

after the script runs i check the log, the echo after (usr/bin/killall DirectoryService) returns 'no matching processes were found'

Script result: Unbinding the computer from Active Directory...
Restarting Directory Services...
No matching processes were found

(but the computer gets unbound to AD, so that is fine, but just curious on the DirectoryService process) anyone understand/know what is happening? I kinda have a feeling but not sure.

sometimes the policy results in 'FAILED' while other times 'COMPLETED', even though both logs show the same echo information.

I added exit $? to the end of the script, so the log shows 'script exit code: 1' on both 'FAILED' & 'COMPLETED' logs.

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

Are you talking about this script? https://jamfnation.jamfsoftware.com/viewProductFile.html?id=135&fid=438

If so, look at the publish date on it, from 2011. The issue is that directoryservice is no longer the running service that controls that. Its now called opendirectoryd.
So the main problem is the age of the script and the fact that it was written for OS X 10.6 or so, and not for anything released from Apple in the last 5 years. I believe DirectoryService was replaced by opendirectoryd back around 10.7, just to give you an idea.

You need to be careful about just using scripts posted here that have not had any activity or updated on them for a number of years. There are bound to be issues with at least some of these older scripts since the OS is a moving target.

OTOH, if that wasn't the script you're talking about, can you post a link to the one you used so we can look at it? I wasn't finding anything in the Scripts repository here with the name you posted.

View solution in original post

5 REPLIES 5

mm2270
Legendary Contributor III

Are you talking about this script? https://jamfnation.jamfsoftware.com/viewProductFile.html?id=135&fid=438

If so, look at the publish date on it, from 2011. The issue is that directoryservice is no longer the running service that controls that. Its now called opendirectoryd.
So the main problem is the age of the script and the fact that it was written for OS X 10.6 or so, and not for anything released from Apple in the last 5 years. I believe DirectoryService was replaced by opendirectoryd back around 10.7, just to give you an idea.

You need to be careful about just using scripts posted here that have not had any activity or updated on them for a number of years. There are bound to be issues with at least some of these older scripts since the OS is a moving target.

OTOH, if that wasn't the script you're talking about, can you post a link to the one you used so we can look at it? I wasn't finding anything in the Scripts repository here with the name you posted.

tcandela
Valued Contributor II

@mm2270 yep, that is the script i am talking about.

HISTORY

# Version: 1.0

- Created by Nick Amundsen on August 7th, 2008

tcandela
Valued Contributor II

I switched the one liner from

usr/bin/killall DirectoryService

to

usr/bin/killall opendirectoryd

i'll give it a test run sometime soon

mm2270
Legendary Contributor III

OK, well, while you can use killall, looks like there is another way of restarting it. Consider using the following:

/bin/launchctl stop com.apple.opendirectoryd

According to the launchctl man page, many services that are "on demand" will just restart when asked to "stop" using launchctl. opendirectoryd happens to fit that description. Take a look. Note the new process ID after using the stop command.

$ ps axwww | grep [o]pendirectoryd
$ 4196   ??  Ss     0:29.83 /usr/libexec/opendirectoryd
$ sudo /bin/launchctl stop com.apple.opendirectoryd
$ ps axwww | grep [o]pendirectoryd
$ 4292   ??  Ss     0:00.89 /usr/libexec/opendirectoryd

tcandela
Valued Contributor II

usr/bin/killall opendirectoryd

Script exit code: 0
Script result: Unbinding the computer from Active Directory...
Restarting Directory Services...