views:

164

answers:

2

I would like to know from Java code if the machine that I'm on is running active directory or that it has active directory installed (e.g. service may be stopped). Is there a reliable registry key to inspect? This is specifically for Windows 2008.

I found info on the web that mentions HKLM\SOFTWARE\Microsoft\MSDTC\Security\DomainControllerState, but that value is 0 on my domain controller as well as on my normal windows 7 machine!?

+1  A: 

Is using the registry as means to determine if the AD service is running mandatory or can you use WMI instead? E.g. jWMI

String name = getWMIValue("Select * from Win32_Service WHERE State = 'Stopped'", "Name");

See also WMI

AlexanderN
Thanks, more mandatory really, but easier to do. WMI might just work, thanks.
Hannes de Jager
+1  A: 

I did a search on stackoverflow & found this solution, hope it helps to resolve your issue.

http://stackoverflow.com/questions/324484/how-to-check-if-a-active-directory-server-is-up-and-running-using-net

SoftwareGeek
Thanks, thats .NET code though. don't think its going to work for my java solution.
Hannes de Jager
SoftwareGeek
It certainly is. But I would prefer a more elegant solution. But thanks, will keep this in mind if it comes to that.
Hannes de Jager