/// <summary> /// Find all UDDI sites registered in Active Directory and log warnings for any invalid sites. /// </summary> /// <returns>A collection of invalid site locations from Active Directory.</returns> private static IEnumerable <UddiSiteLocation> FindAndCacheRegisteredUddiSites() { // The flag indicating whether a UDDI site location was successfully cached. Func <string, UddiSiteLocation, bool> isCached = // Determine if the site location was cached: (keyValue, site) => !string.IsNullOrWhiteSpace(site.InquireUrl) && Uri.IsWellFormedUriString(site.InquireUrl, UriKind.RelativeOrAbsolute) && (Contains(keyValue) || Add(keyValue, site, new CacheItemPolicy())); // The unique key value to be used in the cache. Func <UddiSiteLocation, string> key = site => // Get the unique cache key value: // If the inquiry URL is well-formed and absolute Uri.IsWellFormedUriString(site.InquireUrl, UriKind.Absolute) ? // then use it as the key: site.InquireUrl : // else generate a new key as a GUID. Guid.NewGuid().ToString(); // Clear the cache of all previously discovered sites. // ReSharper disable once ReturnValueOfPureMethodIsNotUsed Cache.Where(item => item.Key != "DefaultUDDIInquiryService").Select(item => Cache.Remove(item.Key)).ToList(); // Find and cache sites, returning a collection any invalid sites. // NB. The Find method doesn't throw errors. Any exception is silently consumed in the Microsoft.Uddi library. // When an error occurs, it is possible for the returned collection to be partially populated with discovered sites. // There is no way of telling if Find is broken. return (from site in UddiSiteDiscovery.Find(UddiSiteUrlType.Inquire, AuthenticationMode.WindowsAuthentication) where isCached(key(site), site) == false select site); }
/// <summary> /// Searches Active Directory for Uddi Sites, using the specified Authentication /// Mode as criteria for the search. /// </summary> /// <param name="mode"> The authentication mode you would like to query for.</param> /// <returns>The first UddiSiteLocation registered with Active Directory.</returns> private static UddiSiteLocation GetFirstLocation(AuthenticationMode mode) { UddiSiteLocation[] locations = UddiSiteDiscovery.Find(UddiSiteUrlType.All, mode); if (locations.Length > 0) { return(locations[0]); } else { return(null); } }