我在SharePoint场机器上运行了一些代码(控制台应用程序),我需要该应用程序来确定该服务器场的管理中心网站的网址。我记得看到一些SharePoint API正在做这件事,但我现在找不到它。如何以编程方式获取管理中心网站网址?
我见过一堆人正在使用的黑客,如在Windows注册表中查找它,但我需要通过SharePoint API的方式。
我在SharePoint场机器上运行了一些代码(控制台应用程序),我需要该应用程序来确定该服务器场的管理中心网站的网址。我记得看到一些SharePoint API正在做这件事,但我现在找不到它。如何以编程方式获取管理中心网站网址?
我见过一堆人正在使用的黑客,如在Windows注册表中查找它,但我需要通过SharePoint API的方式。
Microsoft.SharePoint.Administration.SPAdministrationWebApplication centralWeb =
SPAdministrationWebApplication.Local;
为了从@RDeVaney答案扩大:
Microsoft.SharePoint.Administration.SPAdministrationWebApplication centralWeb =
SPAdministrationWebApplication.Local;
string centralAdminUrl = centralWeb.Sites[0].Url;
下面是从MSDN代码,请参阅如果它可以回答你的问题
SPWebServiceCollection webServices = new SPWebServiceCollection(SPFarm.Local);
foreach (SPWebService webService in webServices)
{
foreach (SPWebApplication webApp in webService.WebApplications)
{
if (!webApp.IsAdministrationWebApplication)
{
get the URL here
}