Chris, I'm also slowly building up some help around accessing information from 
Lists like you will do in the foreach loop.

http://www.sharepointdevwiki.com/display/public/Accessing+List+Items+using+SPList+using+the+object+model
I'd be interested in your feedback here, the whitepaper external link is most 
definitely worth a read if you haven't read it already.

If anyone has the time and some sample code they can fill in the gaps on this 
page the community would be really grateful!

From: [email protected] [mailto:[email protected]] On Behalf Of Chris Grist
Sent: Thursday, February 12, 2009 7:15 AM
To: [email protected]
Subject: RE: webpart issue

Legend, thanks!

From: [email protected] [mailto:[email protected]] On Behalf Of Gerald De Run
Sent: Thursday, 12 February 2009 8:23 AM
To: [email protected]
Subject: RE: webpart issue

Chris,

Try the following code (added using statements and subWeb.Dispose to properly 
dispose of SPSite / SPWeb objects):

using (SPSite site = new SPSite("http://urlhost/edu/projects";))
{
    using(SPWeb web = site.OpenWeb())
    {
        foreach(SPWeb subWeb in web.GetSubwebsForCurrentUser())
        {
             // Code to process sub webs
             subWeb.Dispose();
        }
    }
}

Regards,
Gerald de Run

From: [email protected] [mailto:[email protected]] On Behalf Of Chris Grist
Sent: Thursday, 12 February 2009 8:47 AM
To: [email protected]
Subject: RE: webpart issue

Thanks for that.

Using that command, it seems to go right up to the root of the site collection 
i.e.:  http://urlhost/

And get the sub webs there, is there any way to get the sub webs just for 
http://urlhost/edu/projects


From: [email protected] [mailto:[email protected]] On Behalf Of Gerald De Run
Sent: Thursday, 12 February 2009 8:00 AM
To: [email protected]
Subject: RE: webpart issue

Chris,

The second line of code is causing the permission denied error.  The AllWebs 
property is not available for normal users.
You can try using siteCollection.RootWeb.GetSubwebsForCurrentUser() to return 
the SPWeb objects available to the current user.

Regards,
Gerald de Run

From: [email protected] [mailto:[email protected]] On Behalf Of Chris Grist
Sent: Thursday, 12 February 2009 8:26 AM
To: [email protected]
Subject: webpart issue

Hi Guys,

Ive written a simple web part to rollup from several sites some information 
from some identical lists.

It works perfect for me (Site Collection Admin), however for normal users it 
does not, I have checked and even with full control over all the sites the 
outcome is the same, basically they get a permission denied page when the web 
part is loaded.

The main two lines of code that I would imagine are effecting it are:

                SPSite siteCollection = new 
SPSite("https://urlhost/edu/projects";);
                SPWebCollection webs = siteCollection.AllWebs;

Would this be causing them to get a permission denied error?


Chris Grist
Technical Officer, ICT Systems
Education.au Limited

Level 1, 182 Fullarton Road
DULWICH SA 5065

p +61 8 83343291
f  +61 8 83343211

e [email protected]<mailto:[email protected]>
w www.educationau.edu.au<http://www.educationau.edu.au/>


________________________________
IMPORTANT: This e-mail, including any attachments, may contain private or 
confidential information. If you think you may not be the intended recipient, 
or if you have received this e-mail in error, please contact the sender 
immediately and delete all copies of this e-mail. If you are not the intended 
recipient, you must not reproduce any part of this e-mail or disclose its 
contents to any other party. This email represents the views of the individual 
sender, which do not necessarily reflect those of Education.au except where the 
sender expressly states otherwise. It is your responsibility to scan this email 
and any files transmitted with it for viruses or any other defects. 
education.au limited will not be liable for any loss, damage or consequence 
caused directly or indirectly by this email.
________________________________
Support procedure: https://www.codify.com/lists/support
List address: [email protected]
Subscribe: [email protected]
Unsubscribe: [email protected]
List FAQ: http://www.codify.com/lists/ozmoss
Other lists you might want to join: http://www.codify.com/lists
________________________________
Support procedure: https://www.codify.com/lists/support
List address: [email protected]
Subscribe: [email protected]
Unsubscribe: [email protected]
List FAQ: http://www.codify.com/lists/ozmoss
Other lists you might want to join: http://www.codify.com/lists

________________________________
IMPORTANT: This e-mail, including any attachments, may contain private or 
confidential information. If you think you may not be the intended recipient, 
or if you have received this e-mail in error, please contact the sender 
immediately and delete all copies of this e-mail. If you are not the intended 
recipient, you must not reproduce any part of this e-mail or disclose its 
contents to any other party. This email represents the views of the individual 
sender, which do not necessarily reflect those of Education.au except where the 
sender expressly states otherwise. It is your responsibility to scan this email 
and any files transmitted with it for viruses or any other defects. 
education.au limited will not be liable for any loss, damage or consequence 
caused directly or indirectly by this email.
________________________________
Support procedure: https://www.codify.com/lists/support
List address: [email protected]
Subscribe: [email protected]
Unsubscribe: [email protected]
List FAQ: http://www.codify.com/lists/ozmoss
Other lists you might want to join: http://www.codify.com/lists
________________________________
Support procedure: https://www.codify.com/lists/support
List address: [email protected]
Subscribe: [email protected]
Unsubscribe: [email protected]
List FAQ: http://www.codify.com/lists/ozmoss
Other lists you might want to join: http://www.codify.com/lists

________________________________
IMPORTANT: This e-mail, including any attachments, may contain private or 
confidential information. If you think you may not be the intended recipient, 
or if you have received this e-mail in error, please contact the sender 
immediately and delete all copies of this e-mail. If you are not the intended 
recipient, you must not reproduce any part of this e-mail or disclose its 
contents to any other party. This email represents the views of the individual 
sender, which do not necessarily reflect those of Education.au except where the 
sender expressly states otherwise. It is your responsibility to scan this email 
and any files transmitted with it for viruses or any other defects. 
education.au limited will not be liable for any loss, damage or consequence 
caused directly or indirectly by this email.
________________________________
Support procedure: https://www.codify.com/lists/support
List address: [email protected]
Subscribe: [email protected]
Unsubscribe: [email protected]
List FAQ: http://www.codify.com/lists/ozmoss
Other lists you might want to join: http://www.codify.com/lists
--------------------------------------------------------------------------------
Support procedure: http://www.codify.com/lists/support
List address: [email protected]
Subscribe: [email protected]
Unsubscribe: [email protected]
List FAQ: http://www.codify.com/lists/ozmoss
Other lists you might want to join: http://www.codify.com/lists

Reply via email to