Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Readers Access Rights on a web context though OM

  Asked By: Rey    Date: Mar 25    Category: Sharepoint    Views: 825

I have a web part that need to check who has Readers Access Rights on a web context though OM.

Here is a code Snippet:

SPUserCollection sp = web.Roles["Reader"].Users;

Foreach(SPRole oRole in sp)
{
Something…
}

I am always asked to Enter User Name and Password on running this. And then the exception is thrown : You don’t have access to DB.

I am an Administrator and have full access. I have assigned my User Name on AppPool also. Still no result!!! It should be very simple but what hell going on with this code!

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Sharonda Mcfarland     Answered On: Mar 25

Download the wsssdk and lookup impersonation. You have to specifically impersonate an authorized user  in your code.

 
Answer #2    Answered By: Harshini Raju     Answered On: Mar 25

his is standard behavior.

1. To avoid the dialog box Web.Parentsite. CatchAccessDeniedException = false;
Will stop throwing dialog box and allow to catch the exception

2. Retrieving Roles required elevated privileges so you will need to impersonate user  with a administrator  and revert went completed

 
Answer #3    Answered By: Christop Mcfadden     Answered On: Mar 25

Actually, in WSS v2, any code  dealing with Roles runs in an Application
Domain (one of four) that was created using the HTTP context  of the
current user  (not the application pool). So, the thread identity does
not have access  to the database.

This is a tough nut to crack. Maurice's article on this is the best I've
seen on the subject:
www.bluedoglimited.com/.../ViewPost.aspx?ID=7

I ended up using a secondary AppDomain but we are planning on using Web
Services this next time around.

 
Didn't find what you were looking for? Find more on Readers Access Rights on a web context though OM Or get search suggestion and latest updates.




Tagged: