1

Is it possible to check if a sites exists using a non admin account. I would like to check if a site exists and even better, check if I have access.

I know how to do this querying the sharepoint admin url and using Tenant but this user does not have access to the SharePoint admin area so this will not work for me. I've tried

            using (ClientContext clientContext = new ClientContext(siteUrl)) {
            clientContext.Credentials = _credentials;
            Web web = clientContext.Web;
            clientContext.Load(web, w => w.Title, w => w.Webs);
            clientContext.ExecuteQuery();
            Console.WriteLine(web.Webs.Count); }

and us the following url https://tenant.sharepoint.com

2

Rather than using the ClientContext to access the SharePoint site, you could just use a general http request using WebClient, and if the request returns a 404 then the site doesn't exist,but if it returns a 403 then the user doesn't have access.

You will need to pass an auth cookie in your request however, the details of setting this up can be seen here

http://charlesemes.blogspot.com.au/2015/03/accessing-sharepoint-online-with-web.html

  • thanks, looks like that will work for what I want. This will return a 403 error if I am not allowed to access the site. – Webfort Mar 4 '16 at 11:08
  • Yep, was just checking that myself, 403 when permissions not granted to site. – Paul Lucas Mar 4 '16 at 11:16

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.