views:

124

answers:

3

I've got an internal C# application that I want to start deploying externally. I've got features that I only want available to internal users, but I don't want to bother with multiple releases. I also don't want to change the way that internal users are currently using the program.

So, what I'm thinking is: 1) Check the domain of the PC that the program is running on. If it's my company's domain, then turn on the internal features. The program may run on PCs that are disconnected from the domain and running offline.

2) Have a password option on top of that to enable internal features.

So, for internal users on domain machines, it looks exactly the same as it always did. For internal users on non-domain machines, they have the ability to turn on the internal features. For external users, they don't get the internal features.

What's the best way to implement the "is the computer part of a domain, even if offline" in C#?

+3  A: 

Check Environment.UserDomainName.

Filip Navara
+2  A: 
Console.WriteLine(Environment.UserDomainName);
tomfanning
+1  A: 

I think it's more complicated than that, because that would be easy to look for and createa spoofing domain.

I'd suggest setting a specific value in your LDAP directory and looking through LDAP for that value (possibly with some encryption to make it more difficult). This would have the advantage you want without being quite so easily bypassed.

It could still be bypassed, just not quite so easily.

Hounshell
Good catch on the spoofing, I was thinking the same thing. I'm not too worried about it for this software though.
XPav