开发者

C# Remote Server Unique Identifier for License [duplicate]

This question already has answers here: Is there really any way to uniquely identify any computer at all (5 answers) Closed 7 years ago.

I am writing a basic licensing class for our program. I would like to tie this license to the server so they cannot move the license and expect it to work.

The program is run locally on each workstation from a shared drive on the server. Majority of our customers run on a peer 2 peer network since they are smaller co开发者_JS百科mpanies and only have a few computers.

I'd like to get a unique identifier for the server so when the workstation starts the application, it will verify the license is running against the correct server.

I have almost completed the class except I cannot figure out how to get a consistent unique identifier for the server.

Also, I am writing this in C#.net.

Any suggestions?

Thanks!


Sounds like you want the computer's Security Identifier (SID).

string fqdn = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).HostName;

int firstDot = fqdn.IndexOf('.');
string host = fqdn.Substring(0, firstDot);
string domain = fqdn.Substring(firstDot + 1);

NTAccount account = new NTAccount(domain, host + "$");
SecurityIdentifier sid =
    (SecurityIdentifier)account.Translate(typeof(SecurityIdentifier));

// we're done, show the results:
Console.WriteLine(account.Value);
Console.WriteLine(sid.Value);

(Code to get identifier copied from here. Tested, though. It works.)

In reference to the discussion below, the way that would be most "gentle" to your users is to license by host name. This is the way dotNetCharting does it (or did it a few years ago when I bought their software). Basing on hardware or the computer's SID is prone to change and necessitates relicensing/activation when the hardware changes or the OS is re-installed. The first line in the code above returns the fully qualified domain, which you could use for this purpose.


Get the serial number of the CPU and system harddrive and mainboard then hash it. You can off course mix up what hardware serials/models information you take.

Article on codeproject that explains how to get the information: http://www.codeproject.com/KB/system/GetHardwareInformation.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜