Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Access denied error while reading user roles

  Asked By: Seth    Date: Sep 15    Category: Sharepoint    Views: 1467

I am an admin on the box and also Administrator on the SharePoint
Portal server. But while retrieving the user roles from the SPWeb
object, I get the error "Access is denied".

Here is the code :

foreach (SPRole role in SPWEB.Roles)
{
foreach(SPUser user in role.Users)
{
Response.Write(user.LoginName);
}
}

Exception is thrown on reading role.Users.

Any idea why this is happening? Since I am an admin I shouldn't be
seeing this error?

Share: 

 

6 Answers Found

 
Answer #1    Answered By: Chandra Manjrekar     Answered On: Sep 15

I assume it is a web application - If yes check the
application pool it is running under. Run this pool
under your identity and then troubleshoot backwards.

 
Answer #2    Answered By: Lora Wall     Answered On: Sep 15

Have u tried impersonating admin  id in the code
i think that should allow u to read the user  names

 
Answer #3    Answered By: Mahendra Parte     Answered On: Sep 15

Not sure, since you're an admin. We solved the problem by creating a web
service that runs on the server  under a privilaged (admin) account, as this was
the only reliable way we could get the data at run-time.

 
Answer #4    Answered By: Sue Alford     Answered On: Sep 15

No, it's a windows application...............

 
Answer #5    Answered By: Devon Welch     Answered On: Sep 15

Where is the application being run? OM calls are not remoteable - this code
MUST run on the SPS server.

 
Answer #6    Answered By: Sridhar Tantry     Answered On: Sep 15

Code is being run on the SPS server.

 
Didn't find what you were looking for? Find more on Access denied error while reading user roles Or get search suggestion and latest updates.




Tagged: