Samba+Windows: Allow multiple connections by different users?

23

21

I have a machine running Ubuntu with Samba that I use to share stuff with my family's Windows machines in our local network. Currently they access a share for movies/music/etc with one user.

I want to connect them to another share as a different user (for example, user "goytacaz").

When I try connecting to this new share, Windows gives me "Error 1219" and complains about multiple connections by the same user.

How do I get my machine to accept multiple connections by the same user?

rgoytacaz

Posted 2010-01-14T17:12:17.863

Reputation:

Are you just looking to connect using samba? Samba already supports this AFAIK. – heavyd – 2010-01-14T17:32:25.513

Answers

24

Over Samba? There shouldn't be any problems; as long as the username & password are correct both connections should happen correctly.

Update: re: "Error 1219". This is a client-side error -- Windows only allows you to connect to a server as one user at a time. (See Microsoft documentation at KB938120.) This means the Windows machine has already connected as a different user, and so your attempts to connect again, as the correct user, are failing.

You need to disconnect the first connection before you can reconnect. Two ways I know of to do that:

  • Disconnect any reconnect-at-logon network drives from that server. Reboot. Reconnect to the server and make sure you give the proper username and password.

  • Use the net use /delete command from Windows' command shell (Start -> Run -> cmd; at the prompt type the command; you may need to specify a share name).

Update 2: If the users are already connecting to the server with one user, you won't be able to let them connect with a second user. You'll have to reconsider your share strategy, and reconfigure Samba to follow that strategy. (This isn't your fault; I blame Windows.)

Personally, I'd stick with individual users for each person, and consider using groups to control access to the shares. This works well if you have some shares that you want everyone to have read-write access to, and others that you want to be read-only for all but a select few users.

Update 3: The MS document linked above offers these two workarounds to enable connecting to the server as separate users. The general idea is, make Windows think it's connecting to a different server by using a different name.

  1. Use the IP address of the server when you connect with the second username. (Use \\ServerName\sharename when connecting as the first user, but use \\X.X.X.X\sharename when connecting as the second user.)

  2. Create one or more DNS alias(es) for the server to use when you connect with the second (, third, fourth...) username. (Use \\ServerName\sharename when connecting as the first user, but use \\ServerAlias1\sharename when connecting as the second user, \\ServerAlias2\sharename when connecting as the third user, etc.)

quack quixote

Posted 2010-01-14T17:12:17.863

Reputation: 37 382

1Thank you for this answer. I had the same issue, and connecting using the server's IP address instead of DNS name worked for me for the second connection. – Ben Torell – 2010-05-25T15:43:33.313

10

This is a solution for Windows 7 (although it might work for other versions as well)

  1. open Notepad (or any text editor) as Administrator
    (you have to right click and say 'run as Administrator')

  2. find : c:\WINDOWS\system32\drivers\etc\hosts (you will need to show all files not only .txt)

Now, if i.e. :
- you have 3 samba users: tom fred jon
- 3 samba shares on your samba server (i.e. IP: 192.168.0.100): docs stuff pics
- you want to connect as tom to docs, as fred to stuff and as jon to pics

Now add the following lines to the hosts file:

192.168.0.100   tomsdocs   tomsdocs
192.168.0.100   fredstuff  fredstuff
192.168.0.100   jonspics   jonspics

Once you close and save you can "Map a network drive" like so:

\\tomsdocs\docs as user tom
\\fredstuff\stuff as user fred
\\jonspics\pics as user jon

Note that the names above are totally up to you ... Whatever you put into the hosts file will need to mach what you call the server when you map the network drive.

The reason this works, is because windows needs to think it is connecting to different servers. Arguably, you could also set up your own home DNS server, but I prefer faking a bunch of entries in the hosts file (which gets evaluated before your windows machine asks the DNS for help).
Since the entire problem is a client side windows problem, I prefer doing it this way.

Hope this helps.

Sebastian

Posted 2010-01-14T17:12:17.863

Reputation: 101

Thank you for this. I hate having to work around the new crap the Microsoft spews out, but this is elegant if not goofy... works great! – SuperJames – 2015-09-05T18:09:43.307

1Curious though, are double names a typo? Why would you use the exact same ones twice for the same IP? – brezanac – 2016-03-09T21:51:55.800

This worked like a charm! Fiddled for an hour with the samba share on the server until I found this - Thanks :) – lorem monkey – 2013-09-02T23:19:29.850

8

If you prefer to not fiddle with each client to solve a server issue, you can use the smb.conf file to setup name aliases for the server. This has the added benefit of each alias showing up as distinct server in the Windows Network.

Edit your smb.conf file and add the following entry in the [global] section:

[global]
...
netbios aliases = alias1 alias2 readonly


After a restart of samba (remember to restart smbd AND nmbd!) you should be able to access the new server aliases using UNC notation in the Windows Explorer.
Note that it might take a little time, at my site about 1 Minute after the samba-restart, for them to work.
Once the aliases show up in the Windows Network you're definitely good to go.

Line40

Posted 2010-01-14T17:12:17.863

Reputation: 81

2

i was just having the same issue.

for one user i use: \192.168.x.x <-- IP of the ubuntu server for the other user: \server-name <-- hostname of the ubuntu server.

this allowed me to connect with a windows machine using different logins.

Eric

Posted 2010-01-14T17:12:17.863

Reputation: 21

2

use the IP address (or host name if you use the IP address) of the server

http://support.microsoft.com/kb/938120

leetkrew

Posted 2010-01-14T17:12:17.863

Reputation: 21

1

Use netbios alias samba option:

netbios name = share1
netbios aliases = share2

windows will "see" 2 different samba servers and you can connect to both share with different user authentication

Pol Hallen

Posted 2010-01-14T17:12:17.863

Reputation: 217