In Central Administration\Manage Web Applications, there is the ability to enable anonymous access on a web application through the authentication providers. Is there a way to programmatically determine if this option is enabled? Thanks!

2 Answers 2

$authprov = Get-SPAuthenticationProvider -WebApplication [web application URL] -Zone [zone]
# Check the AllowAnonymous property:

Should return true or false


  • Thanks for the reply. Though I should have specified in my original post that I was looking for how to do this in c#, but I appreciate your answer.
    – athom
    Oct 25, 2012 at 15:22

I should have specified in my post, but I was looking for how to do this in C#. I got the answer I was looking for in this link. Here's the code I basically wound up using by utilizing the IisSettings property of the SPWebApplication object:

Dictionary<SPUrlZone, SPIisSettings> settings = webApplication.IisSettings;

foreach (KeyValuePair<SPUrlZone, SPIisSettings> setting in settings)
    bool allowAnon = setting.Value.AllowAnonymous;

    //TODO handle stuff with this info

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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