private static bool TryParseVersion(string versionString, out Version version) { if (versionString == null) { version = new Version(0, 0, 0, 0); return(false); } Match match = ConfigurationOverrides.VersionRegex.Match(versionString); if (match != null) { int major = ConfigurationOverrides.ParseInt(match.Groups[1].Value); int minor = ConfigurationOverrides.ParseInt(match.Groups[2].Value); int num = ConfigurationOverrides.ParseInt(match.Groups[3].Value); int revision = ConfigurationOverrides.ParseInt(match.Groups[4].Value); if (num > 30000) { num -= 30000; } version = new Version(major, minor, num, revision); return(true); } version = new Version(0, 0, 0, 0); return(false); }
protected override Dictionary <string, string> Read() { DateTime utcNow = DateTime.UtcNow; Dictionary <string, string> dictionary = new Dictionary <string, string>(); Version obj = new Version(); try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); obj = executingAssembly.GetName().Version; AssemblyFileVersionAttribute[] array = executingAssembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true) as AssemblyFileVersionAttribute[]; if (array != null && array.Length > 0) { obj = new Version(array[0].Version); } } catch (Exception ex) { Log.LogErrorMessage("ConfigurationOverrides: Exception '{0}' while reading version numbers.", new object[] { ex }); } try { string adpath = ConfigurationOverrides.GetADPath(); using (DirectorySearcher directorySearcher = new DirectorySearcher(new DirectoryEntry(adpath), "(objectClass=msExchMonitoringOverride)", ConfigurationOverrides.OverrideProperties, SearchScope.OneLevel)) { using (SearchResultCollection searchResultCollection = directorySearcher.FindAll()) { foreach (object obj2 in searchResultCollection) { SearchResult searchResult = (SearchResult)obj2; DirectoryEntry directoryEntry = searchResult.GetDirectoryEntry(); string property = ConfigurationOverrides.GetProperty(directoryEntry, "msExchConfigurationXML"); MatchCollection matchCollection = ConfigurationOverrides.AddKeyRegex.Matches(property); string key; string value; if (matchCollection.Count == 1) { key = matchCollection[0].Groups[1].Value; value = matchCollection[0].Groups[2].Value; } else { key = ConfigurationOverrides.GetProperty(directoryEntry, "name"); value = property; } string property2 = ConfigurationOverrides.GetProperty(directoryEntry, "msExchADCGlobalNames"); DateTime t; if (!DateTime.TryParse(property2, out t) || !(utcNow > t)) { string property3 = ConfigurationOverrides.GetProperty(directoryEntry, "msExchMonitoringOverrideApplyVersion"); Version version; if (!ConfigurationOverrides.TryParseVersion(property3, out version) || version.Equals(obj)) { dictionary[key] = value; } } } } } } catch (COMException ex2) { if (ex2.ErrorCode != -2147016656) { Log.LogErrorMessage("ConfigurationOverrides: Exception '{0}' while reading AD configuration overrides.", new object[] { ex2 }); } } catch (Exception ex3) { Log.LogErrorMessage("ConfigurationOverrides: Exception '{0}' while reading AD configuration overrides.", new object[] { ex3 }); } return(dictionary); }