summaryrefslogtreecommitdiff
path: root/source3/stf/osver.py
diff options
context:
space:
mode:
authorcvs2svn Import User <samba-bugs@samba.org>2003-03-18 07:09:24 +0000
committercvs2svn Import User <samba-bugs@samba.org>2003-03-18 07:09:24 +0000
commit74d3be021897d47e04a4ebecc484d16621b93c9d (patch)
treeb6551b8c36820b2d5c9d24c4531dd0f14dc7ed97 /source3/stf/osver.py
parent417bf608f4253fadf4b227b5f7360f03b0193ff2 (diff)
parenta084f06fe33eb9903489763bc34c7092080a0a5e (diff)
downloadsamba-74d3be021897d47e04a4ebecc484d16621b93c9d.tar.gz
samba-74d3be021897d47e04a4ebecc484d16621b93c9d.tar.bz2
samba-74d3be021897d47e04a4ebecc484d16621b93c9d.zip
This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to be commit f0d009c3e91979b0dc3443e16f3f545bcc64cfda)
Diffstat (limited to 'source3/stf/osver.py')
-rwxr-xr-xsource3/stf/osver.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/source3/stf/osver.py b/source3/stf/osver.py
new file mode 100755
index 0000000000..68601fa7bb
--- /dev/null
+++ b/source3/stf/osver.py
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+#
+# Utilities for determining the Windows operating system version remotely.
+#
+
+from samba import srvsvc
+
+# Constants
+
+PLATFORM_UNKNOWN = 0
+PLATFORM_WIN9X = 1
+PLATFORM_NT4 = 2
+PLATFORM_NT5 = 3 # Windows 2000
+
+def platform_name(platform_type):
+
+ platform_names = { PLATFORM_UNKNOWN: "Unknown",
+ PLATFORM_WIN9X: "Windows 9x",
+ PLATFORM_NT4: "Windows NT",
+ PLATFORM_NT5: "Windows 2000" }
+
+ if platform_names.has_key(platform_type):
+ return platform_names[platform_type]
+
+ return "Unknown"
+
+def platform_type(info101):
+ """Determine the operating system type from a SRV_INFO_101."""
+
+ if info101['major_version'] == 4 and info101['minor_version'] == 0:
+ return PLATFORM_NT4
+
+ if info101['major_version'] == 5 and info101['minor_version'] == 0:
+ return PLATFORM_NT5
+
+ return PLATFORM_UNKNOWN
+
+def is_domain_controller(info101):
+ """Return true if the server_type field from a SRV_INFO_101
+ indicates a domain controller."""
+ return info101['server_type'] & srvsvc.SV_TYPE_DOMAIN_CTRL
+
+def os_version(name):
+ info = srvsvc.netservergetinfo("\\\\%s" % name, 101)
+ return platform_type(info)
+
+if __name__ == "__main__":
+ import sys
+ if len(sys.argv) != 2:
+ print "Usage: osver.py server"
+ sys.exit(0)
+ info = srvsvc.netservergetinfo("\\\\%s" % sys.argv[1], 101)
+ print "platform type = %d" % platform_type(info)
+ if is_domain_controller(info):
+ print "%s is a domain controller" % sys.argv[1]