0

Trying to find a C# script that will list me all the groups of Current Web for sake of webpart that will show users the groups and users having permission to a specific web.

I know I can get all the users by following code,

foreach (SPUser user in SPContext.Current.Web.Users)
            {
}

but then how can I actually access the Permissions List and then Access the properties of the Items.

I find this relevant webpart which is related to what I want but, its listing all the webs a user have access to, In my case I want to List all the Users/Groups have access to the Site

Cheers

2

The code below will give you the groups and the users in the groups.

foreach (SPGroup group in SPContext.Current.Web.Groups)
{
    foreach (SPUser user in group.Users)
    {

    }
}

Additionally, there is SPWeb.AllUsers wich represents all users who are members of the web or who have browsed to the site because they have access via a domain group.

SPWeb.Users only gives you the users that have been added to the web explicity (i.e. outside the comfort of a SharePoint or domain group).

  • +1 for the difference between AllUsers and Users – Hitodama Nov 20 '12 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.