Reputation: 333
Users who have permission to the sub site but not to the top level site are getting access denied error when I use SPContext.Current.Site.SystemAccount.UserToken in my web part added to the sub site. Only after I give them read acces to the top level site they are not getting access denied error.
Can anyone please let me know where am I going wrong. Thanks.
Upvotes: 2
Views: 1365
Reputation: 968
It seems to be a normal behavior of limited access to SPContext.Current.Site.SystemAccount.UserToken for users with restricted privileges. Just image that the property SystemAccount is a member of site collection SPContext.Current.Site for which current user in sub site has no rights.
But if you wish to get SPContext.Current.Site.SystemAccount.UserToken anyway you can do it with SPSecurity.RunWithElevatedPriviliges
Upvotes: 3