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

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!

share|improve this question

2 Answers 2

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

Should return true or false

http://myspworld.wordpress.com/2012/05/31/anonymous-claims-authentication/

share|improve this answer
    
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. –  Alex T Oct 25 '12 at 15:22
up vote 0 down vote accepted

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
}
share|improve this answer

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.