请求所有网站的计数时访问被拒绝 - SharePoint WSS 3.0 SP2

发布于 2024-09-08 02:19:41 字数 479 浏览 4 评论 0原文

我试图列出所有 SharePoint 网站(父网站和子网站)上的所有链接。当我以管理员用户身份登录时,它工作得很好。但是,当我以普通用户身份登录时,出现访问被拒绝错误。当我检查 SPWebCollection 的 count 属性时,会引发错误。

SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsite = oSiteCollection.AllWebs;

StringBuilder labelText = new StringBuilder();

for (int i = 0; i < collWebsite.Count; i++) // <---- Access denied on count
{ // get links }

我尝试添加给我的普通用户完整的站点控制权,但我仍然收到访问被拒绝的错误。知道访问 count 属性时正在检查什么访问规则吗?

I'm trying to list all the links on all the SharePoint web sites (parent and sub). When I'm logged in as the admin user it works just fine. However, when I sign on as a normal user I get an access denied error. And the error is thrown when I check the count property of the SPWebCollection.

SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsite = oSiteCollection.AllWebs;

StringBuilder labelText = new StringBuilder();

for (int i = 0; i < collWebsite.Count; i++) // <---- Access denied on count
{ // get links }

I tried adding giving my normal user full site control and I still received the access denied error. Any idea what access rule is being checked when accessing the count property?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灼痛 2024-09-15 02:19:41

您可以尝试使用 SPSecurity 上的 RunWithElevatedPrivileges 方法来使用应用程序池的帐户。

SPSecurity.RunWithElevatedPrivileges(delegate()
{
   SPSite oSiteCollection = SPContext.Current.Site;
   SPWebCollection collWebsite = oSiteCollection.AllWebs;

   StringBuilder labelText = new StringBuilder();

   for (int i = 0; i < collWebsite.Count; i++) // <---- Access denied on count
   { // get links }
});

You can try and use your application pool's account using the RunWithElevatedPrivileges method on SPSecurity.

SPSecurity.RunWithElevatedPrivileges(delegate()
{
   SPSite oSiteCollection = SPContext.Current.Site;
   SPWebCollection collWebsite = oSiteCollection.AllWebs;

   StringBuilder labelText = new StringBuilder();

   for (int i = 0; i < collWebsite.Count; i++) // <---- Access denied on count
   { // get links }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文