1

I want to identify a windows share. My c# program is launched from a network share on different clients and I want to ensure that all client can only be started from one share on one server.

Is it possible to get the same information if my clients use e.g. this three pathes:

\\server01\MyShare
\\172.16.0.1\MyShare
Z:\

Maybe windows/samba offers a gui for every share.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Biber
  • 709
  • 6
  • 19
  • Not quite sure I understand your problem but how about checking Application.StartupPath (Windows Forms) respectively AppDomain.CurrentDomain.BaseDirectory (Console Application)? – LocEngineer Apr 29 '15 at 09:56
  • 2
    Putting together LocEngineers comment and some of the answers to [How do I determine a mapped drive's actual path](http://stackoverflow.com/q/2067075/205233) should give you a working solution. – Filburt Apr 29 '15 at 10:06
  • But if I use the above comments I can't see that e.g. this domains are the same: server01, server01.mycompany.org, server01.localdomain, 172.16.0.1. Maybe I can resolve the domains to the IP, but It seems to me like botch. I would prefer another way if there is one. – Biber Apr 29 '15 at 12:16

1 Answers1

1

This sounds like the issue raised some years ago trying to find unique machine identifiers to be used when registering licenses online.

I remember that some companies started calculating ID's based on the hardware and all the problems that raised.

You can check the followings posts with relevant information:

Unique computer identifier Is there really any way to uniquely identify any computer at all

You will see that it is not a problem with a response valid in all the possible usecases so you will need to do some trade offs.

Community
  • 1
  • 1
Ignacio Soler Garcia
  • 21,122
  • 31
  • 128
  • 207
  • That's what I want, but my Problem is, that I have no process on the server. I have only the client's processes which are launched directly from the UNC-Path. – Biber Apr 29 '15 at 12:58
  • Then I guess the only way to achieve that is to have a service application on the server telling the magic number to the clients. – Ignacio Soler Garcia Apr 29 '15 at 13:54
  • I think that's the most proper way to do this. But if I do so, the Samba-Server (Linux Server, NAS-Server,..) will get left out. Probably I have to figure out the MAC-Adress of every share and use that one to identify the server. As I write in a comment before I don't like this solution, but I think that's the only way. – Biber Apr 29 '15 at 14:05
  • Please be aware that this still has issues. A machine can have different LAN cards with different MACs serving the same share. And MACs can be spoofed. All the solutions have hard edges ... – Ignacio Soler Garcia Apr 29 '15 at 14:16