tags:

views:

65

answers:

3

Hi,

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

A: 

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();
    }
});
JWL_
A: 

Hey, thank you. I have tried this before, but it doesnt work :( Now I found a code snippet which works fine. The only problem is, that the impersonation doesnt change the domain.

the code I found you can see here: http://www.codeproject.com/KB/dotnet/UserImpersonationInNET.aspx?display=Print

Instead of the console I used a Label.

I hope someone can help me fix this problem.

Sebastian

Sebastian
A: 

I decided now to use webservice, because I get a FileNotFoundException when I want to access to the attachment under Impersonation. I cant find any solution for this problem, so I will try with webservice... But there is another problem. I only get the url of the attachment and not a file... Also I have not the permission to view the url... Why it must be so complicated?

If you can help me, please ansewer to my new Question ("get attachments via webservice").

Thanks, Sebastian

Sebastian