public IIs70() { if (IsIISInstalled()) { // New implementation avoiding locks and other sync issues winAuthSvc = new WindowsAuthModuleService(); anonymAuthSvc = new AnonymAuthModuleService(); basicAuthSvc = new BasicAuthModuleService(); defaultDocSvc = new DefaultDocsModuleService(); classicAspSvc = new ClassicAspModuleService(); httpRedirectSvc = new HttpRedirectModuleService(); extensionsSvc = new ExtensionsModuleService(); customErrorsSvc = new CustomHttpErrorsModuleService(); customHeadersSvc = new CustomHttpHeadersModuleService(); webObjectsSvc = new WebObjectsModuleService(); dirBrowseSvc = new DirectoryBrowseModuleService(); mimeTypesSvc = new MimeTypesModuleService(); handlersSvc = new HandlersModuleService(); } }
public void AddBinding(SSLCertificate certificate, WebSite website) { using (ServerManager srvman = GetServerManager()) { // Not sure why do we need to work with X.509 store here, so commented it out and lets see what happens X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine); store.Open(OpenFlags.ReadOnly); // List<ServerBinding> bindings = new List<ServerBinding>(); // Retrieve existing site bindings to figure out what do we have here WebObjectsModuleService webObjSvc = new WebObjectsModuleService(); bindings.AddRange(webObjSvc.GetSiteBindings(srvman, website.SiteId)); // Look for dedicated ip bool dedicatedIp = bindings.Exists(binding => String.IsNullOrEmpty(binding.Host) && binding.IP != "*"); // string bindingInformation; // bindingInformation = dedicatedIp ? string.Format("{0}:443:", website.SiteIPAddress) : string.Format("{0}:443:{1}", website.SiteIPAddress, certificate.Hostname); // srvman.Sites[website.SiteId].Bindings.Add(bindingInformation, certificate.Hash, store.Name); // store.Close(); // srvman.CommitChanges(); } }