Sharepoint Forum

 
Home » Forum » Sharepoint       Ask a questionRSS Feeds

Code Access Security? Or user's permissions?

  Asked By: Dane Schultz         Date: Feb 22, 2003      Category: Sharepoint      Views: 281
 

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.

Tagged:            

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Code Access Security? Or user's permissions? Or get search suggestion and latest updates.


Your Answer
  • Answer should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].