static DirectoryContext() { OperatingSystem oSVersion = Environment.OSVersion; if ((oSVersion.Platform == PlatformID.Win32NT) && (oSVersion.Version.Major >= 5)) { if ((oSVersion.Version.Major == 5) && (oSVersion.Version.Minor == 0)) { w2k = true; dnsgetdcSupported = false; OSVersionInfoEx ver = new OSVersionInfoEx(); if (!System.DirectoryServices.ActiveDirectory.NativeMethods.GetVersionEx(ver)) { int lastError = System.DirectoryServices.ActiveDirectory.NativeMethods.GetLastError(); throw new SystemException(Res.GetString("VersionFailure", new object[] { lastError })); } if (ver.servicePackMajor < 3) { serverBindSupported = false; } } GetLibraryHandle(); } else { platformSupported = false; serverBindSupported = false; dnsgetdcSupported = false; } }
static DirectoryContext() { DirectoryContext.platformSupported = true; DirectoryContext.serverBindSupported = true; DirectoryContext.dnsgetdcSupported = true; DirectoryContext.w2k = false; OperatingSystem oSVersion = Environment.OSVersion; if (oSVersion.Platform == PlatformID.MacOSX || oSVersion.Platform == PlatformID.Unix) { return; } if (oSVersion.Platform != PlatformID.Win32NT || oSVersion.Version.Major < 5) { DirectoryContext.platformSupported = false; DirectoryContext.serverBindSupported = false; DirectoryContext.dnsgetdcSupported = false; return; } else { if (oSVersion.Version.Major == 5 && oSVersion.Version.Minor == 0) { DirectoryContext.w2k = true; DirectoryContext.dnsgetdcSupported = false; OSVersionInfoEx oSVersionInfoEx = new OSVersionInfoEx(); bool versionEx = NativeMethods.GetVersionEx(oSVersionInfoEx); if (versionEx) { if (oSVersionInfoEx.servicePackMajor < 3) { DirectoryContext.serverBindSupported = false; } } else { int lastError = NativeMethods.GetLastError(); object[] objArray = new object[1]; objArray[0] = lastError; throw new SystemException(Res.GetString("VersionFailure", objArray)); } } DirectoryContext.GetLibraryHandle(); return; } }
internal static extern bool GetVersionEx( [In, Out] OSVersionInfoEx ver);
static DirectoryContext() { // // Everything supported until proven otherwise // s_platformSupported = true; s_serverBindSupported = true; s_dnsgetdcSupported = true; s_w2k = false; // // S.DS.AD only supported on W2K above // OperatingSystem os = Environment.OSVersion; if (os.Platform == PlatformID.Win32NT && os.Version.Major >= 5) { if (os.Version.Major == 5 && os.Version.Minor == 0) { // // This is W2K: DsGetDcOpen/Next/Close not supported // s_w2k = true; s_dnsgetdcSupported = false; // // Now get the service pack information as well to check if ADS_SERVER_BIND // is supported (Could not have used OSVersionInfoEx earlier itself as it is not // supported on all platforms) // OSVersionInfoEx osviex = new OSVersionInfoEx(); bool result = NativeMethods.GetVersionEx(osviex); if (!result) { int errorCode = NativeMethods.GetLastError(); Debug.Fail(string.Format(CultureInfo.InvariantCulture, "NativeMethods.GetVersionEx (with OSVERSIONINFOEX) failed with error code {0}.", errorCode)); throw new SystemException(Res.GetString(Res.VersionFailure, errorCode)); ; } if (osviex.servicePackMajor < 3) { // // ADS_SERVER_BIND is not supported on platforms prior to W2K SP3 // s_serverBindSupported = false; } } // load ntdsapi.dll for AD and ADAM GetLibraryHandle(); } else { // // S.DS.AD does not support this platform (< 5.0) // s_platformSupported = false; s_serverBindSupported = false; s_dnsgetdcSupported = false; } }
static DirectoryContext() { // // Everything supported until proven otherwise // s_platformSupported = true; s_serverBindSupported = true; s_dnsgetdcSupported = true; s_w2k = false; // // S.DS.AD only supported on W2K above // OperatingSystem os = Environment.OSVersion; if (os.Platform == PlatformID.Win32NT && os.Version.Major >= 5) { if (os.Version.Major == 5 && os.Version.Minor == 0) { // // This is W2K: DsGetDcOpen/Next/Close not supported // s_w2k = true; s_dnsgetdcSupported = false; // // Now get the service pack information as well to check if ADS_SERVER_BIND // is supported (Could not have used OSVersionInfoEx earlier itself as it is not // supported on all platforms) // OSVersionInfoEx osviex = new OSVersionInfoEx(); bool result = NativeMethods.GetVersionEx(osviex); if (!result) { int errorCode = NativeMethods.GetLastError(); Debug.Fail(string.Format(CultureInfo.InvariantCulture, "NativeMethods.GetVersionEx (with OSVERSIONINFOEX) failed with error code {0}.", errorCode)); throw new SystemException(String.Format(CultureInfo.CurrentCulture, SR.VersionFailure, errorCode));; } if (osviex.servicePackMajor < 3) { // // ADS_SERVER_BIND is not supported on platforms prior to W2K SP3 // s_serverBindSupported = false; } } // load ntdsapi.dll for AD and ADAM GetLibraryHandle(); } else { // // S.DS.AD does not support this platform (< 5.0) // s_platformSupported = false; s_serverBindSupported = false; s_dnsgetdcSupported = false; } }
static DirectoryContext() { DirectoryContext.platformSupported = true; DirectoryContext.serverBindSupported = true; DirectoryContext.dnsgetdcSupported = true; DirectoryContext.w2k = false; OperatingSystem oSVersion = Environment.OSVersion; if (oSVersion.Platform == PlatformID.MacOSX || oSVersion.Platform == PlatformID.Unix) return; if (oSVersion.Platform != PlatformID.Win32NT || oSVersion.Version.Major < 5) { DirectoryContext.platformSupported = false; DirectoryContext.serverBindSupported = false; DirectoryContext.dnsgetdcSupported = false; return; } else { if (oSVersion.Version.Major == 5 && oSVersion.Version.Minor == 0) { DirectoryContext.w2k = true; DirectoryContext.dnsgetdcSupported = false; OSVersionInfoEx oSVersionInfoEx = new OSVersionInfoEx(); bool versionEx = NativeMethods.GetVersionEx(oSVersionInfoEx); if (versionEx) { if (oSVersionInfoEx.servicePackMajor < 3) { DirectoryContext.serverBindSupported = false; } } else { int lastError = NativeMethods.GetLastError(); object[] objArray = new object[1]; objArray[0] = lastError; throw new SystemException(Res.GetString("VersionFailure", objArray)); } } DirectoryContext.GetLibraryHandle(); return; } }
internal static extern bool GetVersionEx(OSVersionInfoEx ver);