Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm developing a little installer for some SharePoint features that contain some web parts and a custom Web Service that's used to communicate with a 3rd party application that reads information from some electronic components.

Everything is working fine, but to make it work, i had to enable Anonymous Authentication on my SharePoint's server IIS. I can easily programmatically achieve this on my windows forms installer using the code below:

using (ServerManager serverManager = new ServerManager())
{
    Configuration config = serverManager.GetApplicationHostConfiguration();
    ConfigurationSection anonymousAuthenticationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", "Sharepoint - 80");
    anonymousAuthenticationSection["enabled"] = true;
    anonymousAuthenticationSection["userName"] = txtUserName.Text;
    anonymousAuthenticationSection["password"] = txtPassword.Text;
    serverManager.CommitChanges();
}

But now, i came across something that can be a problem. If i try to use this installer on a Sharepoint Farm, the IIS modification will be applied only on that specific server.

Is there a way to achieve the same result, but applying the modification to all servers on the farm using a Event Receiver on my webpart project?

Thanks a lot.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

As a good practice, deploying SharePoint customizations should always be done via features, packaged into solutions. This way, SharePoint takes care of the deployment to all web servers in the farm. Of course there are also other benefits such as help with upgrading your features. More info:

Modifying the web.config on every server can also be done via SharePoint: take a look at the SPWebConfigModification class:

You could develop an event receiver that fires when your feature is activated so it makes the web.config modification.

However, In the case of enabling anonymous authentication this should be done via the SharePoint web application settings:

share|improve this answer
    
Thank you Thomas, but i don't believe that specific change is kept on the web.config file. I manually changed the options on my IIS Manager and the web.config file of my application didn't have any modifications on it. And reading on the documentation of the ServerManager class, it says that this class initialize the object based on the ApplicationHost.config file. –  C. Hoffmann Jan 23 '13 at 20:12
add comment

You want to do this with the SPIisSettings class. There is a method in that class called AllowAnonymous which you can set to True and then update the object. That will enable Anon for the Web Application on the specified zone.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spiissettings_members.aspx

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.