Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to dynamically build a collection of all sites a given use has access to, now I've tried SPWeb.GetSubwebsForCurrentUser() but this only returns the sub sites under the current site the user is accessing, for example:

Admininstrations
  - Users
  - Permissions

If the user is currently browsing default.aspx under Administration, GetSubwebsForCurrentUser() will return Users and Permissions, but not Administration. Now I can include this in my collection, but what about the other webs at the root?

For example:

Home (has access)
  - Catalog (admin only)
       - Products (admin only)
       - Administration (admin only)
  - Administration (has access + all subs)
       - Users
       - Permissions
  - Site 1 (has access)

Should produce a collection like follows:

Home
  - Administration
       - Users
       - Permissions
  - Site 1

So I had a look at passing search queries across, but I don't have search services enabled on the system, as we don't need it, so that won't work.

Also had a look SPContext.Current.Site.RootWeb.GetSubwebsForCurrentUser() but this throws an exception of call stack when trying to iterate through the collection and I can't figure out why, that said, if it throws an exception I can safely assume the user does not have access, but as you can imagine, if my site is massive, an iterative check like this will take some time.

So the question, is there an easier way to determine the levels a user has access to, without querying SQL directly, because that's my last resort.

share|improve this question
add comment

1 Answer

why not use the OOB Table of content webpart & then style it using XSLT.

I believe it will internally apply security.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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