VincentRothwel replied on 27-Mar-07 06:05 PM
I suspect that even though you user has domain and local admin rights, it
does not have any rights in SharePoint.

Can you ensure that the user you are impersonating is in at least one
SharePoint group...Administrators, Members, Visitors etc.

HTH, Vince

--
http://blog.thekid.me.uk


SharePoint - System.UnauthorizedAccessException: Access is denied.

Asked By denz on 27-Mar-07 06:55 PM
I have problem with my own web part
when I run next code

im.Impersonate();
SPSite spwRoot = new SPSite(PortalRootUrl).OpenWeb().Site;
foreach (SPWeb web in spwRoot.AllWebs)
{
//some code
}

it fail with next exception

Exception System.UnauthorizedAccessException: Access is denied. (Exception
from HRESULT: 0x80070005 (E_ACCESSDENIED))
at Microsoft.SharePoint.Utilities.SPUtility.HandleAccessDenied(Exception
ex)
at
Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException ex)
at Microsoft.SharePoint.Library.SPRequest.GetAllWebsOfSite(String
bstrUrl, Object& pvarWebs, Object& pvarWebIds, Object& pvarParentWebs,
Object& pvarLangs, Object& pvarTitles)
at
Microsoft.SharePoint.SPSite.SPWebCollectionProvider.GetWebsData(String[]&
strNames, String[]& strServiceRelUrls, Guid[]& guidWebIds, Int32[]&
nLanguages, String[]& strTitles, String[]& strDescriptions, String[]&
strCreationTimes, String[]& strModifiedTimes, Boolean[]& bUserIsWebAdmins,
Int32[]& nWebTemplates, Int16[]& nProvisionConfigs, Int16[]& nMeetingCounts)
at Microsoft.SharePoint.SPWebCollection.EnsureWebsData()
at Microsoft.SharePoint.SPWebCollection.Undirty()
at
Microsoft.SharePoint.SPBaseCollection.System.Collections.IEnumerable.GetEnumerator()

impersonated user have domain admin and local admin rights.

how I can solve this problem?

I found people with same problem http://forums.asp.net/thread/1487916.aspx
but there no ansvers...
denz replied on 28-Mar-07 05:08 AM
In Shrepoint groups I do not see group Administrotor, but this user already
added in
Home Owners (Full control) and I add it in Farm Administrator group, it
does not help.