没有有效权限网站用户的权限返回"打开"在SharePoint 2013 SP1中

时间:2015-09-07 16:37:44

标签: c# permissions sharepoint-2013 spweb

我想检查具有站点权限的当前用户,可在SSOM中编程。

我在Visual Studio 2013中为控制台应用程序创建。

但是我在一个SharePoint场中获得了有趣的结果。

At"网站收集功能"部分,我已经激活了#SharePoint; SharePoint Server Publishing Infrastructure"

在这种情况下,SharePoint Group" Style Resource Readers"创建并包含" Everyone"。 然后我尝试了这个程序"没有网站许可"用户。

        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;
        }

在所有4个农场中,3个农场返回" Open" 。我认为这个原因是样式资源读者包含"每个人"

但是,1个农场未经许可。

所以我的问题。  在相同的代码中,相同的解决方案,为什么结果不同?

所以如果有人知道这个案子,请告诉我。

0 个答案:

没有答案