How to mount a Windows shared drive on OS X given a Windows user like this: myserver@mydomain.com

Posted on

QUESTION :

I have a script in OS X which is something like this:

tell application "Finder"
    try
        mount volume "SMB://myuser:mypwd@myhost/sharedfolder"
    end try
end tell

It works fine, but now there is an additional share with the credentials like so:

myuser1@mydomain.com 

If I add the following line to the script, it fails:

tell application "Finder"
    try
        mount volume "SMB://myuser:mypwd@myhost/sharedfolder"
        mount volume "SMB://myuser:myuser1@mydomain.com@myhost/sharedfolder1"
    end try
end tell

Can anybody tell how I should configure my script to get it working?

ANSWER :

One of these solutions might work (no access to a Mac at the moment):

  1. Escape the first @

    mount volume "SMB://myuser:myuser1@mydomain.com@myhost/sharedfolder1"`
    
  2. Play with the quotes. Try

    mount volume "SMB://myuser:'myuser1@mydomain.com'@myhost/sharedfolder1"
    

    or

    mount volume 'SMB://myuser:"myuser1@mydomain.com"@myhost/sharedfolder1'
    

Are you sure you need to specify the domain? Don’t see why of the first mount succeeds. Unless the actual username is myuser1@mydomain.com which, unless I am missing something obvious, seems silly.

The standard way of encoding @ in URLs is using URL-encoding, which results in %40 (@ is ASCII 40h) – so use myuser%40mydomain.com.

You can gain access to the SMB share by specifying your Windows login and the machines IP address like this:

mount -t cifs -o username=winuser,password=winpass //192.168.0.105/myshare /mnt/share

Leave a Reply

Your email address will not be published. Required fields are marked *