Web 部件:模拟/RunWithElevatedPrivileges

发布于 2024-09-13 02:51:25 字数 520 浏览 13 评论 0原文

我正在使用 MOSS 07 & WindowsServer2003 上的 VisualStudio 07 (c#)

我的问题是我想要从一个 Sharepoint 访问另一个 Sharepoint。 在SharePoint_1中有一个SPList,我想从SharePoint_2中读出。

我的研究结果是 IMPERSONATION 和 RUN_WITH_ELEVATED_PRIVILEGES。 通过模拟我可以读出我所连接的SPSite的html代码,但是我怎样才能得到我想要的列表呢? 当我尝试 RunWithElevatedPrivileges 时,我必须从 SharePoint_1 的网站获取用户。但由于 FileNotFoundException,我无法获取用户(即使我知道了他的名字)。

我该如何解决这个问题?

谢谢

有件事我忘记告诉了。 列表中有附件,我也需要访问它们。

解决这个问题的最佳方法是什么? 希望这不是很棘手,因为我 5 周前第一次使用 Sharepoint,感觉不太熟悉:)

谢谢

I am using MOSS 07 & VisualStudio 07 (c#) on a WindowsServer2003

My Problem is that I want to have access from one Sharepoint to another.
In SharePoint_1 is a SPList I want to read out from SharePoint_2.

The results of my research are IMPERSONATION and RUN_WITH_ELEVATED_PRIVILEGES.
With impersonation I can read out the html code of the SPSite I am connected with, but how can I get the List I want?
When I try to RunWithElevatedPrivileges I have to take a user form the site of SharePoint_1. But I cant get the User (even if I got his name) because of a FileNotFoundException.

How can I solve the problem?

Thanks

There is something I forgot to tell.
In the List are Attachments and I need access to them, too.

What would be the best way to solve this issue?
Hopefully its not very tricky, because I used Sharepoint 5 weeks ago the first time and dont so feel very familiar with it :)

Thanks

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

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

发布评论

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

评论(1

四叶草在未来唯美盛开 2024-09-20 02:51:25

使用 SPSecurity.RunWithElevatedPrivileges 时无需指定用户。 就可以了

我认为如果您使用: [url] = 指向其他网站集的 url

SPSecurity.RunWithElevatedPrivileges(() => {
    using (var site = new SPSite("[url]")) {
        using (var web = site.OpenWeb()) {
            // Access list here
        }
        site.RootWeb.Dispose();
    }
});

You dont need to specify a user when using SPSecurity.RunWithElevatedPrivileges. I think you will be ok if you use:

[url] = url to the other site collection

SPSecurity.RunWithElevatedPrivileges(() => {
    using (var site = new SPSite("[url]")) {
        using (var web = site.OpenWeb()) {
            // Access list here
        }
        site.RootWeb.Dispose();
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文