在 SharePoint 2010 中读取特定服务应用程序的帐户权限的最佳/最简单方法是什么?目前我一直在搞乱:
var solution = SPFarm.Local.Solutions["Service App Name.wsp"];
var solutionPermissions = solution. //trying different options here
我一直在寻找可以遵循“解决方案”的不同选项。但到目前为止,我很茫然。有任何想法吗?
在 SharePoint 2010 中读取特定服务应用程序的帐户权限的最佳/最简单方法是什么?目前我一直在搞乱:
var solution = SPFarm.Local.Solutions["Service App Name.wsp"];
var solutionPermissions = solution. //trying different options here
我一直在寻找可以遵循“解决方案”的不同选项。但到目前为止,我很茫然。有任何想法吗?
您可以通过 PowerShell 尝试此操作。您可以从您的代码运行脚本并尝试以这种方式与权限进行交互。
以及如何从您的代码运行 PowerShell:http: //www.codeproject.com/Articles/18229/How-to-run-PowerShell-scripts-from-C
如何检查服务应用程序的权限?可能对您有用:
foreach (SPService service in SPFarm.Local.Services)
{
if (service.Name.Equals("ServiceName"))
{
foreach (SPServiceApplication serviceApp in service.Applications)
{
//This gets the service app administrators
SPCentralAdministrationSecurity serviceAppSecurity = serviceApp.GetAdministrationAccessControl();
SPAcl<SPCentralAdministrationRights> adminAcl = serviceAppSecurity.ToAcl();
foreach (SPAce<SPCentralAdministrationRights> rights in adminAcl)
{
//Handle users
}
//This gets the users that can invoke the service app
SPIisWebServiceApplication webServiceApp = (SPIisWebServiceApplication) app;
SPIisWebServiceApplicationSecurity webServiceAppSecurity = webServiceApp.GetAccessControl();
SPAcl<SPIisWebServiceApplicationRights> invokerAcl = webServiceAppSecurity.ToAcl();
foreach (SPAce<SPIisWebServiceApplicationRights> rights in invokerAcl)
{
//Handle users
}
}
}
}