So you want to know how many days until your password expires in Active Directory (AD)? Here's the meat of the code you can run on any AD-bound OS X box, so long as your shortname is the same as the AD name:
I've created a 28KB zip file (ADexpire.zip; Hints mirror) that contains adexpirre.sh, adexpire.php, and adexpire.scpt (and application version) for client/server setup (with code comments). This works for the situation many are in at my work: their machines aren't bound to AD and they don't often log into the file services on an AD server to find out their password expiration! This allows one server to field queries and return a value via http to an AppleScript that runs as a login item.
Hopefully this will help someone else and even better; maybe someone way smarter than me does it in five lines in Perl! ;) Looking forward to the comments and revisions.
If, like me, you connect to many different networks (I'm a network consultant), then you probably find OS X's ability to create different locations a most useful tool. But how to back them up to reinstall or tranfer to a new machine? After a long search, eureka! They're all in one single file:
I have a machine at work and one at home (common problem, yes?) and I want to access the one at work from home via VNC. Well, to properly use that I need to login to the VPN and then login to the remote machine -- but I need to know the IP address, and since we use dynamic addressing, you know the rest.
I saw a whole bunch of scripts here for how to have your PowerBook phone home, but they didn't cut it -- too complex and ultimately not what I needed. So I made this simple script:
#Script name: writeip
# Get my Ethernet Adapter IP Address
# And write it to a file
ipconfig getifaddr en0 > ~/Desktop/IP.txt
# Copy that file to my iDisk
cp ~/Desktop/IP.txt /Volumes/<idiskname>/Documents/IP.txt
If I make sure that my iDisk is set to automatically mount on login (using login items you can select a volume to automatically mount), then this script will get my IP address, write it to a file, then copy that file to my iDisk. Simple enough for what I needed. I then set up cron (using Cronnix) to run the script hourly to make sure my IP is current.
[robg adds: Note that this method will return the machine's internal IP address, which won't be its public IP address if you're using a router, for example. Since the author is first connecting to a VPN, this works, as he can then access the machine via its internal IP. If you need the remote machine's public IP (if you're connecting from work to home, for instance, and you have a router at the house), then you'll need to use one of these hints.]
If you and the person you want to iChat to are both behind NATs, you could forward the ports at one or both ends (5060, 5190, 5297, 5298, 5678, 16384-16403). But what if both ends are unable to forward these ports (maybe it's not your network, or you can't) -- you wouldn't be able to iChat.
However, Hamachi supports Bonjour properly, and has an OS X version. If both of you fire up Hamachi, you can use iChat's Bonjour features to chat between you and the other person, over the internet, with audio and video chat. The disadvantage is that the CPU load may be a fair bit higher due to Hamachi's tunneling overhead. It works great for me -- I've done it, doing audio chats on a 12" 1.33GHZ PowerBook G4 to someone on a 1.0GHZ 12" PowerBook, and not noticed any system slowdown.
Is this a hint? It's not obvious to most others -- whenever I suggest it to someone else, I get a strange look from them as if it's a long way round, and usually get told it's not going to work. But it does, and does well.
I have saved a lot of time by using the dual homing cpabilities of OS X - that is, its ability to connect to two networks at the same time. My home network uses a DSL connection and all the printers are wireless, but I prefer a wired cable modem connection when I am at my desk. OS X happily connects me to the internet at the faster cable modem speed, but allows me to print over the AirPort connection to my home network printers.
In my previous occupation, I was able to work on both the office network and through a wireless internet link; the OS just found what I needed on whatever network was required. No muss, no fuss, and no juggling of connections. I am set up to connect automatically to available networks, although AirPort does ask before joining any untrusted access points.
[robg adds: Though not exactly a hint in and of itself, not everyone may know that OS X can use two network connections at once, so I thought it worth publishing this...]
To quickly open an ssh connection from nearly anywhere on your Mac, do the following:
Open TextEdit and type in your connection string in the form of: ssh://firstname.lastname@example.org
Select the whole line and drag and drop it on the Desktop. The result will be a *.inetloc file.
Move the file to any folder you like. I made one named ~/connections that holds all of my *.inetloc files. You can rename this file to whatever you like, and even change its icon.
Now you can drag and drop the *.inetloc file to the Dock, the Finder's Sidebar or Tool bar, or to anywhere else. (It can even be selected with Spotlight)
If you use LaunchBar, open the Launchbar Configuration screen (Command-Y) and add another rule for your connections folder. Now your SSH connections can be opened with LaunchBar. I believe you can do similar with LaunchBar and Quicksilver, enabling quick launching of your SSH shortcuts.
[robg adds: This doesn't seem to work for a few of my sites, which use the domain in the username -- i.e. my command would look like this: ssh://email@example.com@www.mydomain.com. The dual @ signs seem to confuse the ssh command, resulting in an incorrect command format: ssh firstname.lastname@example.org. For my domains that don't use this format, however, this trick works quite well.]
At our office, we have a mixed work environment of Windows and OS X machine. On Windows, you can mount network drives to common directories. For instance P: will take you to //network/pc05/projectsFolder. You can create an alias on OS X to a directory inside a mounted drive, such as this one...
...but I haven't been able to create an alias to the shared folder itself (//network/pc05/projectsFolder).
I have tried to go to the /Volumes directory after mounting the folder and creating an alias from the mounted directory, but this doesn't always work, I don't know why, but sometimes I lose write priveliges if using that alias.
I just found out that if you create an alias to a directory, as in the project1 folder above, you can then use the Get Info (Command-I) command on the alias (with the network drive mounted). Click the Select new original button, and it will let you select the actual directory for the alias (//network/pc05/projectsFolder).
Then you just have to change the name of the alias to projectsFolder, and you have the equivalent of a mounted drive alias. I even created a folder, myNetwork, where I keep the all the aliases. Just put it on the Finder's sidebar, and you can quickly mount your network directories.
MacWorld recently published a list of things they would most like to see in Leopard, and one of the first ones listed was the ability to automatically change a variety of settings according to network location. Several months ago, there was a posting here about a script called locationchanger, and since then, I have significantly expanded upon the original script, so I thought I'd share the fruits of my labors.
locationchanger (20KB download link, MacOSXHints mirror) is designed to automatically reconfigure many programs and resources according to IP address, wireless network ID, or dial-up connections. Currently it's capable of automatically modifying the following:
host file settings
Mail server and account
Location setting in Network Preferences
Additionally, if growl is found, it notifies you of the new IP address, location name, and the hardware device of the new connection. Comments welcome!
[robg adds: I haven't tested this one, but I know that location management is a topic of interest, so here it is. Please read the entire Read Me file before proceeding, as there are important notes in there. There's also a simple uninstall script, in case you change your mind.]
Mac OS X is great in how it allows you to skin a cat in a multiple of ways. Something that frustrated me, though, is the Finder's Sidebar window. You can drag almost anything into it, and those items act like aliases. But what about mounted server shares? Nope. It will not let you drag a share into the Sidebar. So we are forced to use the 'Connect to Server' window. With Automator we can get around these annoyances.