Please visit our new community...

Question Using different credentials for network shares without logging out

 
  • Created:almost 4 years ago
  • Modified:almost 4 years ago
  • Status:resolved

I currently use mounted drives to access my network shares because I want the ability to limit access to the files without having to logout and relogin everytime I make a change.

I am interested to find out what other options there are to accomplish this same task. I use vista32 for my HTPC and Ubuntu Linux for my server (running Samba).

What I currently do is:

I have a login on my HTPC called “theater” (no quote obviously). On my server I have two users setup (others too…but for this example, I will keep it to two). They are: “theater” (with the same password as the user on the HTPC) and “theater-admin” (with its own password of course).

I have two shares setup on the server, each sharing the same folder. One is called VideoRead and the other is called VideoWrite. VideoRead is read only for all users and VideoWrite allows full control to user “theater-admin”.

When “theater” logs in to the HTPC, I have a batch file run that does this:


If Exist v: (

net use v: /delete

) net use v: \UBUNTU\VideoRead

If Exist x: (

net use x: /delete

) net use x: \192.168.1.220\WriteVideo /u:theater-admin “password”


“password” is of course of the password that user. The IP address is the IP address of my server UBUNTU. The reason for this is that Windows will not allow you to connect to the same server with multiple credentials (at least that is what I have read and the only way I could get it to work) but using the IP is kind of a workaround and it “thinks” it is a different server.

What this does is give user theater read-only access to the files (through drive V:, which is not really necessary…since it would have readonly access via the UNC anyway). But, it also give user theater write access via drive X: without every logging out.

So, the wife and kids use the shortcuts I have setup for V: and Mediabrowser uses V:, but when I want to write something I use X: (for example, metabrowser points to X:).

This works great…but of course I am still bound to the mapped drives and would love to just be able to use the UNC directly…but could not figure out how.

As an aside, I have 5 servers setup on my network…3 of them are setup this way. The other two I use in different capacities so it is not relevant.

Here’s hopeing someone has a better solution?

 
  • Hey ulrick, this turned into more of a technical how to and I'm wondering if it is better suited as a type Question instead of pure discussion? If you agree, maybe you could edit it and change the type. – sinjen almost 4 years ago
  • Done. – ulrick65 almost 4 years ago

3 Answers

votes newest oldest
 
  • Created:almost 4 years ago
  • Modified:almost 4 years ago
accepted answer

Oh, this one is easy I think. It looks to me like you only need the last net use command. Try this on a test machine:

Edit your login batch program to only include:

  • net use \\192.168.1.220\WriteVideo /u:theater-admin “password”
  • then..
  • Through the MB config wizard change all your media collections to use the UNC \\Ubuntu\VideoRead
  • Create a desktop shortcut with the following target \\191.168.1.220\WriteVideo

You're done. :)

Now you don’t have to worry about disconnected drives and Media Browser only has read access to your titles. But, when you get ready to change something, you just double click the shortcut on your desktop point to your WRITE share.

-Sinjen

Edit:

Just want to state, you WILL LOSE your playstates for your titles by moving to UNC paths for all your configurations. It might even invalidate the cache on each machine as well. Also note that you are correct in that windows does not allow same/different users to the same resource. Why, when the share names are totally different, it does this I'll never know. However, using mapped drives did not solve that problem for you. The fact that you used IP address in one net use command and the Host name in another is what solves it, which is why you only need the one net use statement for admin.

Edit2:

I also wanted to add another tip to this. As discussed, the limitation to being able to use only one account to access a shared resource is overcome by using the IP address to authenticate to the second share. However that only allows you to do this for two accounts. But, there is also a workaround for this. If you have a DNS server, add an alias for the target. If you only have a home lan setup (typical), then add new host entries to the HOSTS file on each client like so:

192.168.1.103    home-serverRead
192.168.1.103    home-serverWrite
192.168.1.103    home-serverSuperUser

This “tricks” windows into thing you're using a different name for each account. Again, why you have to jump through hoops to do this in windows, I'll never know.

 
  • Don’t forget the double “\” at the beginning of those commands ;–) – FlyGuyAZ almost 4 years ago
  • Guess the tracker is nice and edits it for you. – FlyGuyAZ almost 4 years ago
  • lol, yeah. My guess is that the first slash is seen as an escape character. I'll fix up the post. Thanks for pointing it out. I hadn’t noticed it :( – sinjen almost 4 years ago
 
  • Created:almost 4 years ago

Hmmm…I had no idea you could use Net Use like that without mapping it to a drive letter. I will give it a try and post back.

By the way…you mentioned (in the other thread) that you use a login schedule to run the .bat file. I am using startup, but sometimes this is a problem as it runs to early and the NET USE commands hang for a while (no ability to put a “wait” statement in a batch file). Can you explain how you have that setup?

Thanks.

 
  • NET USE will pick the first available drive letter if you don’t specify one. – FlyGuyAZ almost 4 years ago
  • Actually it doesn’t in this case. What it does is map the share with the alternate credentials so that when you access the UNC, it uses the mapped credentials rather than the current username and password. No mapped drive is created. – ulrick65 almost 4 years ago
 
  • Created:almost 4 years ago

Works slicker than cow slobber!

I knew the solution was because of the IP address vs. server name, but I did not know that NET USE didn’t require a drive letter.

The part about losing playstates is a bummer…but I guess that’s not that big a deal to fix (I don’t use the watched counter for movies anyway…just TV shows).

I think I will wait until the next version of MB to make the switch…do it all at once.

Let me know about how you schedule the login bat file…I am interested to see if getting it out of startup is worth while.

Thanks for the help. I appreciate it!

 
  • Haha. Good deal. I'll post back later on about the on log in triggered schedule entry. I am doing this, but I just want to make sure it’s working properly with some testing first. – sinjen almost 4 years ago
  • Sorry ulrick about not getting back to you. I haven’t been able to do the testing I wanted, I had a hard drive die (I actually knocked it over). So, I've been concentrating on putting together an Unraid box. I'll try and get to it tonight though. – sinjen almost 4 years ago
  • Bummer…nothing I hate worse than failed HD’s (particularly when it’s my own fault!) I have had many over the years. Now I have 14TB on RAID-5 servers…and I am still very nervous about it! – ulrick65 almost 4 years ago
  • About the watched state. Don’t forget if you hover over a season folder, you can press CTRL + W (clear on an MCE remote) to mark the entire season as watched. Makes quick work of marking watched seasons as…err watched. It’s also the same for other media collections, like you main movies library. – sinjen almost 4 years ago
  • Yep…will do. I am looking forward to the weekend and a win 7 upgrade! – ulrick65 almost 4 years ago
  • show 2 more comments