Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Impersonate then access all sites

  Asked By: Bridget    Date: May 19    Category: Sharepoint    Views: 721

This is the final try.

I can't add a stored procedure (as per local 'custom').

I want to impersonate the app pool, then run through all the sites on a web.
This must have been done. I tried, but after impersonating, I am getting
strange results.



5 Answers Found

Answer #1    Answered By: Delbert Frederick     Answered On: May 19

What exactly are your strange results?

Answer #2    Answered By: Kalyan Pujari     Answered On: May 19

The AllWebs returns nothing and or when I thry to loop through the webs in
the site collection it errors ungracefullt (I.e. a try/catch ends up in the

I noted your additional line after the impersonation call, maybe I'll try
that too.

Answer #3    Answered By: Allison Stewart     Answered On: May 19

catch says: Reference not set to an instance of an object

Answer #4    Answered By: Emmett Hyde     Answered On: May 19

One important thing to remember, when you get an object from the SP object model, if it's not valid you still get an object, it's only until you access  a property or field to get get an exception thrown. Thanks to Todd I knew about this issue, and it helped me be aware that it's not like other areas where if you request an object and get a null then you aren't getting your referenced object.

Check that your names for the webs and sites  you are requesting are correct first. It's very tricky trying to track down exactly where you are getting this error at because you won't see it until you access an item in the object.

Answer #5    Answered By: Michelle White     Answered On: May 19

I added your "magic line" within Todd's impersonation routine (in this case
I was doing the impersonation in line in the routine). With the line, it
works, without it, I get "reference not set to an object" when I execute.

Why again is this required??

Didn't find what you were looking for? Find more on Impersonate then access all sites Or get search suggestion and latest updates.