Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Tools / comsvcutil / WasAdminWrapper.cs / 1 / WasAdminWrapper.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.Tools.ServiceModel.ComSvcConfig { using System; using System.ServiceModel.Channels; using System.Diagnostics; using System.DirectoryServices; using System.Configuration; using System.Collections; using System.Collections.Specialized; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Text; using System.Threading; using System.Runtime.InteropServices; using System.Security; using System.ServiceModel; using System.ServiceModel.Configuration; using Microsoft.Tools.ServiceModel; using Microsoft.Tools.ServiceModel.SvcUtil; internal static class WasAdminWrapper { const string webService = "IIS://localhost/w3svc"; const string defaultWebServer = "1"; public static string DefaultWebServer { get { return webService + "/" + defaultWebServer; } } public static bool IsIISInstalled () { try { DirectoryEntry webServiceEntry = new DirectoryEntry(webService); foreach (DirectoryEntry child in webServiceEntry.Children) return true; } catch (COMException) { return false; } return true; } public static string[] GetWebServerNames() { if (!IsIISInstalled ()) return null; try { ListwebServerNames = new List (); DirectoryEntry webServiceEntry = new DirectoryEntry(webService); foreach (DirectoryEntry child in webServiceEntry.Children) { if (child.SchemaClassName.ToUpperInvariant() == "IISWEBSERVER") { webServerNames.Add(webService + "/" + child.Name); // Note, child.Name is a number! the "friendly" name is actually child.Description } } return webServerNames.ToArray(); } catch (COMException ex) { // assume a failure here means that no web servers exist ToolConsole.WriteWarning (SR.GetString(SR.CannotGetWebServersIgnoringWas, ex.ErrorCode, ex.Message)); return null; } } public static string[] GetWebDirectoryNames(string webServer) { if (!IsIISInstalled ()) return null; try { List webDirectoryNames = new List (); DirectoryEntry webServiceEntry = new DirectoryEntry(webServer); foreach (DirectoryEntry child in webServiceEntry.Children) { if (child.SchemaClassName.ToUpperInvariant () == "IISWEBDIRECTORY" || child.SchemaClassName.ToUpperInvariant() == "IISWEBVIRTUALDIR" ) { webDirectoryNames.Add(child.Name); // Must special case the "ROOT" vDir, since most actual vDirs are subchildren of the ROOT vdir of a server. if (child.Name.ToUpperInvariant() == "ROOT") { foreach (DirectoryEntry rootChild in child.Children) { if (rootChild.SchemaClassName.ToUpperInvariant() == "IISWEBDIRECTORY" || rootChild.SchemaClassName.ToUpperInvariant() == "IISWEBVIRTUALDIR") { webDirectoryNames.Add("ROOT" + "/" + rootChild.Name); } } } } } return webDirectoryNames.ToArray(); } catch (COMException ex) { // assume a failure here means that no web directory exist ToolConsole.WriteWarning (SR.GetString(SR.CannotGetWebDirectoryForServer, webServer, ex.ErrorCode, ex.Message)); return null; } } public static bool GetWebDirectoryPath(string webServer, string webDirectory, out string webDirectoryPath) { webDirectoryPath = null; if (!IsIISInstalled ()) return false; if (!webDirectory.ToUpperInvariant().StartsWith("ROOT", StringComparison.Ordinal)) webDirectory = "root/" + webDirectory; string [] webDirectories = GetWebDirectoryNames (webServer ); if (webDirectories == null) return false; bool found = false; foreach (string webDirectoryName in webDirectories ) if (webDirectoryName.ToUpperInvariant () == webDirectory.ToUpperInvariant()) { found = true; break; } if (!found ) return false; DirectoryEntry webDirectoryEntry = new DirectoryEntry(webServer + "/" + webDirectory); try { if (webDirectoryEntry.Properties.Contains("Path")) { webDirectoryPath = (string)webDirectoryEntry.Properties["Path"].Value; return true; } else { return false; } } catch (COMException ex) { // assume a failure here means the dir does not exist ToolConsole.WriteWarning (SR.GetString(SR.CannotGetWebDirectoryPathOnWebDirOfWebServIgnoring, webServer, webDirectory, ex.ErrorCode, ex.Message)); return false; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataServices.cs
- D3DImage.cs
- ToolboxItem.cs
- InputDevice.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- ApplicationHost.cs
- HttpRequestCacheValidator.cs
- BufferAllocator.cs
- EncryptedPackageFilter.cs
- FlowDocumentPageViewerAutomationPeer.cs
- FixedSOMTableCell.cs
- PerformanceCounterPermissionEntry.cs
- DateTimeOffsetStorage.cs
- Brush.cs
- PolyLineSegmentFigureLogic.cs
- DurableInstanceManager.cs
- MetadataPropertyCollection.cs
- FontFamilyConverter.cs
- PerformanceCounter.cs
- ElementMarkupObject.cs
- Base64Encoder.cs
- TransactionOptions.cs
- EncryptedReference.cs
- storepermissionattribute.cs
- XmlSchemaSequence.cs
- PagedDataSource.cs
- ValidationHelpers.cs
- TemplateKeyConverter.cs
- HostVisual.cs
- Formatter.cs
- UpdateManifestForBrowserApplication.cs
- MailSettingsSection.cs
- PostBackOptions.cs
- CompilerTypeWithParams.cs
- IsolatedStorage.cs
- XamlStyleSerializer.cs
- localization.cs
- WebResponse.cs
- SqlDataSourceDesigner.cs
- DBCSCodePageEncoding.cs
- DoubleIndependentAnimationStorage.cs
- RenderDataDrawingContext.cs
- documentsequencetextpointer.cs
- PerformanceCounterLib.cs
- GraphicsPath.cs
- GeneralTransform.cs
- DesignSurfaceEvent.cs
- Privilege.cs
- CurrencyWrapper.cs
- SQLUtility.cs
- PrefixHandle.cs
- RowBinding.cs
- XmlWriterTraceListener.cs
- TextRunTypographyProperties.cs
- UserNameSecurityToken.cs
- MDIClient.cs
- Column.cs
- EntityConnectionStringBuilderItem.cs
- DataGridViewAdvancedBorderStyle.cs
- EventLogPermissionAttribute.cs
- RSAOAEPKeyExchangeFormatter.cs
- ResXResourceSet.cs
- XmlSerializerAssemblyAttribute.cs
- ToolBar.cs
- ValidatingPropertiesEventArgs.cs
- EncoderParameter.cs
- UTF7Encoding.cs
- BinaryCommonClasses.cs
- ContainsRowNumberChecker.cs
- SerializationHelper.cs
- embossbitmapeffect.cs
- Line.cs
- TraceXPathNavigator.cs
- AspNetRouteServiceHttpHandler.cs
- BitmapEffectrendercontext.cs
- ThemeableAttribute.cs
- ScrollChrome.cs
- JsonSerializer.cs
- ClientClassGenerator.cs
- ReadOnlyDictionary.cs
- FileLogRecordEnumerator.cs
- SessionStateUtil.cs
- ToolStripScrollButton.cs
- QueryActivatableWorkflowsCommand.cs
- TemplateBindingExpressionConverter.cs
- IndexExpression.cs
- DispatcherObject.cs
- FileInfo.cs
- SvcMapFile.cs
- RequestCacheEntry.cs
- BitmapEffectCollection.cs
- DataSourceCacheDurationConverter.cs
- Span.cs
- GifBitmapDecoder.cs
- Parser.cs
- Splitter.cs
- DataRowCollection.cs
- SafeEventLogReadHandle.cs
- ChtmlTextBoxAdapter.cs
- FunctionCommandText.cs