Permission who has no effective permission site user returns "Open" in SharePoint 2013 SP1

237 Views Asked by At

I want to check current user which have permission of site, programmable in SSOM.

I had created for console application in Visual Studio 2013.

but I got funny result in one SharePoint farm.

At "Site collection features" section, I had activated "SharePoint Server Publishing Infrastructure" .

In this situation, The SharePoint Group "Style Resource Readers" was created and contains "Everyone". then I tried this program for "No site permission" user.

        string url1 = "http://ServerName/sites/SiteCol1";
        string userName = "i:0#.w|domainname\\username";

        try
        {


            SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    Console.WriteLine("Privilages");

                    using (SPSite oSIte = new SPSite(url1))
                    {
                        using(SPWeb web1 = oSIte.OpenWeb())
                        {
                            Console.WriteLine("checkpermissiion");
                            Console.WriteLine(web1.GetUserEffectivePermissions(userName));
                       }
                    }
                }
                );
       }
        catch (UnauthorizedAccessException ex)
        {
          console.writeline(ex.message);
        }
        catch (Exception ex)
        {

            Console.WriteLine("Catch Exception");
            Console.WriteLine(ex.Message);
        }
        finally
        {
            /
            SPSecurity.CatchAccessDeniedException = true;
        }

In All 4 farms, 3 farms return "Open" . I think this cause was that Style Resource Readers contain "Everyone"

However,1 farms returned no permission.

so my question. In same code, same solution, Why the result is different?

so if anyone know this case, please tell me.

0

There are 0 best solutions below