Access denied after clicking save

Nov 23, 2011 at 2:40 PM


I'm getting a "access denied" error when I click on the save button after clicking to edit a user. Creating and deleting works fine. I'm running the app with RequireSiteAdministrator set to false.

Any ideas?


Nov 23, 2011 at 3:20 PM

I think the problem is that updating another person's SPUser object probably requires more permissions than the user has, if they're not an administrator.  Try updating the code to run with elevated privileges (SPSecurity.RunWithElevatedPrivileges).

Nov 23, 2011 at 3:38 PM

Does not seem to work :(

Nov 23, 2011 at 7:50 PM

In that case i'd probably do a debug on it to find out the exact line causing the access denied, which will hopefully give you a clue as to the problem.  But it's probably a permissions issue.  Also, make sure that the SPSecurity.RunWithElevatedPrivileges is being used properly - you can't use SPContext.Current with it.  You can look at MembershipRequest.cs for an example.

Dec 2, 2011 at 12:44 PM

The error is thrown at "spuser.Update();" in UserEdit.aspx.cs.

I've tried this:
SPSecurity.RunWithElevatedPrivileges(delegate() {

But it does not work but then again I'm not a real developer :)

Dec 2, 2011 at 1:31 PM

That's not going to work because spuser has to be defined within RunWithElevatedPrivileges - check MembershipRequest.cs for examples.  If you do need one on one help and custom code modifications, we do offer that with our support plan. Check