<p>How do I detect if my program runs in an Active Directory environment?</p>

<p>I'm using C# and .Net 2.0</p>

One way might be to query the LOGONSERVER environmental variable.  That'll give the server name of your AD controller... Which, as far as I know, will be blank (or match current workstation? Not sure) if it isn't currently logged into a domain.
Example Usage:
```
```
string ADServer = Environment.GetEnvironmentVariable("LOGONSERVER");
```
```