Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all site collections in a web application

I want to list all site collections under my web application; the purpose is to list all mysites created by users.

Like that:

/members/sites/sqladmin
/members/sites/sqluser
/members/sites/sqluser1
/members/sites/sqluser2
/members/sites/user1
like image 236
markov00 Avatar asked Dec 08 '25 20:12

markov00


1 Answers

For the purpose of accessing all site collections within a given web application there's, quite naturally, the SPWebApplication.Sites property. To get access to a particular web application you can use a code like this:

SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://my-web-app-url:80/"));

(see MSDN here as well).

like image 161
Ondrej Tucny Avatar answered Dec 11 '25 16:12

Ondrej Tucny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!