private void Initialize(Binding binding) { AddAttribute("Protocol", binding.Protocol); AddAttribute("Port", binding.EndPoint.Port.ToString()); if (binding.Host != "") { AddAttribute("HostName", binding.Host); } string address = binding.EndPoint.Address.ToString(); if (address == "0.0.0.0") { address = "*"; } AddAttribute("IPAddress", address); if (CodeGenHelpers.AreEqualCI(binding.Protocol, "https")) { AddAttribute("CertificateStoreName", binding.CertificateStoreName); AddAttribute("CertificateThumbprint", "the thumbprint of the cert you want to use"); } }
public List <SiteDesiredState> BuildSites(IISCodeGenerator.IisPoolAndSitesOptions iisOptions) { ServerManager serverManager = new ServerManager(); List <SiteDesiredState> siteCodeList = new List <SiteDesiredState>(); WebConfigPropertyDesiredStateAssembler gen = new WebConfigPropertyDesiredStateAssembler(); List <WebConfigPropertyDesiredState> authDesiredStateList = gen.GetAuthenticationDesiredStates(); foreach (var site in serverManager.Sites) { var siteName = site.Name; var siteAuthDesiredStateList = authDesiredStateList.Where(a => CodeGenHelpers.AreEqualCI(a.SiteName, siteName)); var siteCode = new SiteDesiredState(site, siteAuthDesiredStateList, iisOptions); siteCodeList.Add(siteCode); } return(siteCodeList); }
public List <WindowsFeature> GetFeatures() { var features = new List <WindowsFeature>(); var featureLookupSupport = GetFeatureLookupSupport(); PowerShell ps = PowerShell.Create(); if (featureLookupSupport == FeatureLookupSupport.GetWindowsFeature) // Windows server >= 2008 { ps.AddCommand("Get-WindowsFeature"); //ps.AddParameter("-online"); // var psResult = ps.Invoke(); var listToProcess = psResult .Where(o => o.Properties["Name"].Value.ToString().StartsWith("Web-")) .OrderBy(o => o.Properties["Name"].Value.ToString()); foreach (var psFeature in listToProcess) { string featureName = (string)psFeature.Properties["Name"].Value; string displayName = (string)psFeature.Properties["DisplayName"].Value; string installed = (string)psFeature.Properties["Installed"].Value.ToString(); var stateStr = (CodeGenHelpers.AreEqualCI(installed, "true")) ? "Present" : "Absent"; var feature = new WindowsFeature(featureName, featureName, stateStr, displayName); features.Add(feature); } } else if (featureLookupSupport == FeatureLookupSupport.GetWindowsOptionalFeature) // Windows 8 version { var x = ps.AddCommand("Get-WindowsOptionalFeature").AddParameter("online"); Collection <PSObject> psResult; psResult = ps.Invoke(); //this call throws a first chance exception that is supressed internally var listToProcess = psResult .Where(o => o.Properties["FeatureName"].Value.ToString().StartsWith("IIS-")) .OrderByDescending(o => o.Properties["State"].Value.ToString()) .ThenBy(o => o.Properties["FeatureName"].Value.ToString()); foreach (var psFeature in listToProcess) { var featureName = (string)psFeature.Properties["FeatureName"].Value; var state = (string)psFeature.Properties["State"].Value.ToString(); var stateStr = (state == "Enabled") ? "Present" : "Absent"; var feature = new WindowsFeature(featureName, featureName, stateStr); features.Add(feature); } } else { var feature = new WindowsFeature("IIS", "Web-Server", "Present", "Correct PowerShell command not present, settting IIS Base"); features.Add(feature); } return(features); }
public List <SiteDesiredState> BuildSites(IISCodeGenerator.IisPoolAndSitesOptions iisOptions) { ServerManager serverManager = new ServerManager(); List <SiteDesiredState> siteCodeList = new List <SiteDesiredState>(); List <WebConfigEntry> configEntryList = new WebConfigEntryAssembler().GetWebConfigEntries(); foreach (var site in serverManager.Sites) { var siteName = site.Name; List <WebConfigEntry> siteConfigEntryList = configEntryList.Where(a => CodeGenHelpers.AreEqualCI(a.SiteName, siteName)).ToList(); var siteCode = new SiteDesiredState(site, siteConfigEntryList, iisOptions); siteCodeList.Add(siteCode); } return(siteCodeList); }