From d48b66e1e8228918ff8a6330da93caeea8bdc762 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 30 Nov 2010 21:18:34 +1100 Subject: [PATCH] wintest Another way to work out if a Windows machine is a DC it's not perfect (may fail on member servers) but it's picks up the difference between standalone and DC OK. Andrew Bartlett --- wintest/wintest.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/wintest/wintest.py b/wintest/wintest.py index c9bd87554e3..5f7bd0a8d53 100644 --- a/wintest/wintest.py +++ b/wintest/wintest.py @@ -341,12 +341,25 @@ class wintest(): def get_is_dc(self, child): child.sendline("dcdiag") - i = child.expect(["is not a Directory Server", "Home Server = "]) + i = child.expect(["is not a Directory Server", "is not recognized as an internal or external command", "Home Server = "]) if i == 0: return False + if i == 1: + child.expect("C:") + child.sendline("net config Workstation") + child.expect("Workstation domain") + child.expect('[\S]+') + domain = child.after + i = child.expect(["Workstation Domain DNS Name", "Logon domain"]) + '''If we get the Logon domain first, we are not in an AD domain''' + if i == 1: + return False + if domain.upper() == self.getvar("WIN_DOMAIN").upper(): + return True + child.expect('[\S]+') hostname = child.after - if hostname.upper() == self.getvar("WIN_HOSTNAME").upper: + if hostname.upper() == self.getvar("WIN_HOSTNAME").upper(): return True def run_tlntadmn(self, child):