i am creating a web part (for a public site) that needs to first see
if you are a site admin or not, and then it will continue to execute
if you are a site admin, else it will show nothing. So, i get the
current
user information, and then check to see if person is admin such as
in this code:
SPWeb rootWeb = SPControl.GetContextSite(Context).RootWeb;
SPRole spRole = rootWeb.Roles["Administrator"];
SPUser currentUser = rootWeb.CurrentUser;
foreach(SPUser roleUser in spRole.Users)
{
if(roleUser.ID.Equals(currentUser.ID))
{
inRole= true;
break;
}
}
This works fine for an authenticated user, but this webpart won't
load when user is coming to
my site via annonymous access. It prompts you to log in.
Is there not a way to access the SP Object model if the user loading
site is anon access? I also tried to install wp into
GAC, and this still didn't help.
I also noticed that if you have the site set as a trusted site in
IE, then this will load ok, but our typical site visitor won't have
this set since we are using SP for our company website.