Search for Sharepoint Examples and Tutorials:   
Banner

Sharepoint Forum

Home » Forum » SharepointRSS Feeds

Code Access Security? Or user's permissions?

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

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?

Tagged:          


 
Hall of Fame|Facebook|Twitter|LinkedIn|Terms of Use|Privacy Policy|Contact us
RSS Feeds: Articles |  Forum |  New Users |  Activity Log |  Interview FAQ |  Poll |  Hotlinks
Copyright © 2005-2011