Find user's current or last logon server (domain controller)

tnielsen
Valued Contributor

I'm writing a script that that requires to know what office they are in without hardcoding ip etc.

Anyone know how to get the logon server? I've seen alot of ways that no longer work. The current working method I have is running: netstat | grep 63657

then pulling the data i want. Is there a cleaner method?

1 REPLY 1

erowan
New Contributor III

Not sure if this helps, but it's what I use here:

"/usr/libexec/PlistBuddy" -c "print 'last used servers:/Active Directory/AD:host'" "/Library/Preferences/OpenDirectory/DynamicData/Active Directory/AD.plist" ;
"/bin/date" ;
"/usr/sbin/systemsetup" -getusingnetworktime -getnetworktimeserver ;