Make mac VPN connections easier

I have an SBS 2003server (it will be replaced with a non-SBS flavor of windows server 2008 soon) at the HQ that users connect too via PPTP VPN. Our branches will also soon be connected through site-to-site VPN through the new firewalls that are ordered. However we have a few mobile mac users that needs to connect to the office while they are on the move, with a variety of connections like3G modems, WIFI and private ADSL.

I have setup for them so that they use the built in VPN connection in OSX which works great. Then they connect to the server shares through the saved smb://serverip shortcut in the finder menu "connect to server".

So all they have to do is, in the menu bar at the top click on the VPN symbol, click on the company name and then go to the finder menu and click "connect to server" and then the saved server and they have access to the files. I have also made a few manuals with pictures and a low-tech language.

The problem is, however, that they want something even simpler when they are on the move. 4 or 5 mouse clicks seems to be too much for them. I am work mostly with windows computers and servers so I am not an expert on mac. Is there a way to script the VPN connection and connect shares in some way on the mac? Or is there perhaps an other way to make things simpler for the users?

Also: When the macs are physically in the same network as the server they see the server share directly under "Macintosh HD" however when they connect through VPN the shares doesn't show until they do the "connect to server" procedure above. Is there a way to fix that as well?
LVL 1
ishtariAsked:
Who is Participating?
 
marookCommented:
Hi,

Well, copy and edit the script above to your needs (correct server IP's etc)
In Script Editor, save your script, and then make a Save as.. and then select Application[ Bundle]

Hand out the small app to the users (ARD, FileWave, LANrev... USB disk..)

Now your users have to:
1: Select the VPN menu, and connect
2: Click the script app (place it in the Dock for easy access)
3: Ahh, there is no step 3.

If this is not good enough, give them a Windows based PC!

Ahh, well - here is an AppleScript that will do the trick under 10.6 (may work on 10.5)
Note: Assumes there is only one VPN connection under your Service (like PPTP)
Change the VPN name to PPTP or change the service label in the script.
If you have more than one VPN configuration, it will connect the one selected!

Best!
tell application "System Events"
	tell current location of network preferences
		set VPNservice to service "PPTP" -- name of the VPN service
		
		--set isConnected to connected of current configuration of VPNservice
		if not my testVPN(VPNservice) then
			connect VPNservice
			say "Connecting VPN for you, lazy ass"
		end if
		-- Give the VPN a moment to connect - could be a loop to test!
		delay 5
		
		if my testVPN(VPNservice) then
			my connectShares()
		end if
	end tell
end tell

--Subrutine to test VPN state
on testVPN(theService)
	tell application "System Events"
		return (connected of current configuration of theService)
	end tell
end testVPN

on connectShares()
	tell application "Finder"
		--delay 0.3
		try
			--mount volume "smb://Servername1/applications"
			--mount volume "smb://servername2/lis"
			--mount volume "smb://servername3/public"
			
		end try
	end tell
end connectShares

Open in new window

0
 
jhyieslaCommented:
Tell them they just need to get a life :)


It is possible to write a script (I'll include a sample below) that would mount all of the shares from an icon that would live on the desktop. But not sure about integrating the VPN connection.
tell application "Finder"
        delay 0.3
        try
                mount volume "smb://Servername1/applications"
                mount volume "smb://servername2/lis"
                mount volume "smb://servername3/public"
                
        end try
        
        delay 0.3
        
end tell

Open in new window

0
 
ishtariAuthor Commented:
Hehe, I wish they would! If you could show me a script that could accomplish that I would be in your debt! :)

is there perhaps a way to automatically run a script when they connect to the VPN? Or perhaps have the script start a preconfigured VPN connection?
0
Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

 
jhyieslaCommented:
That I don't know. I'm not a script Guru. I just wrote the one above to help me easily mount shares that I use every day.
0
 
ishtariAuthor Commented:
Thanks guys!

I got the script to work and it mounted the folders but I can't seem them. They show up when I type mount in the terminal as

//username@192.168.0.5/Gemensam on /Volumes/Gemensam (smbfs, nodev, nosuid, mounted by tore)

But when I click on Macintosh HD they are neither under Volumes or Shares in the right hand pane. Where are they and is it possible to get them right on the desktop so that the users doesn't have to search around for them? Sorry for being a McNoob guys!
0
 
jhyieslaCommented:
I can't speak for anything outside of the script I wrote, but once it's "compiled" it should mount them so that they show in Finder.
0
 
marookCommented:
Ahh,
Just tested the 'mount volume' here, and it's not a Finder command.

So you can strip the 'tell application "Finder"' part, here is the working connectShares() method:
on connectShares()
		--delay 0.3
		try
			--mount volume "smb://Servername1/applications"
			--mount volume "smb://servername2/lis"
			--mount volume "smb://servername3/public"
			
		end try
end connectShares

Open in new window

0
 
jhyieslaCommented:
Actually the script I wrote does work exactly as I have it written and my shares do show in finder. Not sure if adding the connectshares to the mix changed that or not.  I use this script everyday.  Wrote in under 10.5 and it works under 10.6.
0
 
marookCommented:
@jhyiesla:
The 'mount volume' command is no longer a Finder command, it's in StandardAdditions, so there should not be a 'tell finder' part. At least not in 10.6.
If you execute it in AppleScript Editor on 10.6 it errors and move to 'tell AppleScript Editor' and that works.

Moving the mount command to a subrutine does not make a difference, it just makes the code more modular and reusable.
0
 
jhyieslaCommented:
Appreciate the info.  I've not redone the script in the editor since I wrote it.  All I know is that the compiled code works for me everyday and I do see the mounted shares in Finder.  I'll play with it in the editor when I get a chance.
0
 
ishtariAuthor Commented:
My bad! I found the mounted shares under "computer", I am still a bit stuck in my windows thinking and mistakenly thought of "Macintosh HD" as "My Computer" in windows. Sorry for that. (Aa a side note I got the same result with or without the "tell finder" part in the script running 10.5)

However, is there a way for the shares to show up on the desktop in the script?
0
 
jhyieslaCommented:
Think of that Macintosh HD as your C: drive. It's not that it's not useful, but Finder would be more analogous to My Computer

However, having said that, if you open the Macintosh HD it should bring up Finder and the mounted shares should show in Finder.
0
 
marookCommented:
If the volumes mounted does not show on the Desktop, check the Finder preferences, under General:
Screen-shot-2009-12-30-at-14.08..PNG
0
 
ishtariAuthor Commented:
That did the trick, thanks a lot to all that contributed. I hope I can find a fair way to distribute the points between all of you! :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.