Share via


Changing UseDsMapper for site binding

I recently worked on an issue to enable ds mapper usage for our web service to enable x509 authentication. Here is a sample c# code to make this binding change for IIS7 using .NET 3.0.

ServerManager srvMgr = new ServerManager();
Site DefaultSite = srvMgr.Sites["Default Web Site"];//you can also use site id

                foreach (Binding binding in DefaultSite.Bindings)
                {
                    if (binding.Protocol.Equals(URI.UriSchemeHttps, StringComparison.InvariantCultureIgnoreCase))
                    {
                            bindingFound = true; 
                            binding.UseDsMapper = true 
                            break;                               
                    }                       
                }//Commit only if we need to
if(bindingFound)
     srvMgr.CommitChanges();