This is what I'm trying to do in my custom web part when a row is selected
in an SPGridView:
-If the site exists, go to that site and do no further processing.
-If the user has the appropriate permission on the current site, create a
new site for the selected row based off a pre-defined site template.
When I attempted it as myself (an administrator), it worked great. When a
user with contributor rights tried it, he was redirected to an "Accessed
Denied" MOSS page.
To get around this, I tried two separate techniques:
1. Use advapi32.dll (Method RevertToSelf) to impersonate the App pool's
security context.
2. Use advapi32.dll (Method LogonUser) to impersonate myself (An admin).
I used each of these techniques to execute the following VB code:
Dim site As SPSite = New SPSite("CurrentSiteUrl")
site.CatchAccessDeniedException = False
Dim web As SPWeb = site.OpenWeb()
Dim spRole As SPRole = web.Roles(_Role)
On the last line of code, I receive the following exception error:
Permission level cannot be found
Does anybody have any ideas on how to resolve this?