I have a problem with running a very simple webpart.
(I have similar problems with an other webpart.)
I created a strong named webpart and registered it in the BIN and set
the trust=WSS_Medium.
The only code I added to the template is in the 'RenderWebPart(). Beside
some output.write statements.:
===========
SPSite spSite = SPControl.GetContextSite(Context);
SPWeb spWeb = spSite.OpenWeb();
SPRoleCollection spRoleCollection = spWeb.CurrentUser.Roles;
foreach (SPRole userMembership in spRoleCollection)
{
userGroupMemberships = userGroupMemberships +
SPEncode.HtmlEncode(userMembership.Name) + " ";
}
===========
If I run this webpart as administrator all goes well.
If I run the webpart with an account that is a Contributor I'm prompted
for a username&password.
If I remove the foreach statement, the Contributor is allowed to this
webpart.
The webpart behaves exactly the same when placed in the GAC
My conclusion is the Contributor has no richt to inquire the
spWeb.CurrentUser.Roles objects.
How do I grant him these rights? (Of course only for THIS WebPart and
not make him an administrator.)
What am I doing wrong or have I forgotten?
Do you know someone who can help? Share a link to this thread on twitter, or facebook.