Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用对象模型配置sharepoint网站订阅用户帐户目录路径_Sharepoint_Sharepoint 2010_Sharepoint Object Model - Fatal编程技术网

使用对象模型配置sharepoint网站订阅用户帐户目录路径

使用对象模型配置sharepoint网站订阅用户帐户目录路径,sharepoint,sharepoint-2010,sharepoint-object-model,Sharepoint,Sharepoint 2010,Sharepoint Object Model,我正在sharepoint中进行多租户资源调配,我很难确定是否可以使用sharepoint对象模型为网站订阅设置用户帐户目录路径。我知道这可以通过powershell和以下cmdlet完成 $sub = New-SPSiteSubscription $sub | Set-SPSiteSubscriptionConfig -UserAccountDirectoryPath "OU=AlpineBikeStore,OU=Hosting,DC=contoso,DC=com" -Fea

我正在sharepoint中进行多租户资源调配,我很难确定是否可以使用sharepoint对象模型为网站订阅设置用户帐户目录路径。我知道这可以通过powershell和以下cmdlet完成

    $sub = New-SPSiteSubscription 
    $sub | Set-SPSiteSubscriptionConfig -UserAccountDirectoryPath "OU=AlpineBikeStore,OU=Hosting,DC=contoso,DC=com" -FeaturePack "50976ac2-83bb-4110-946d-95b4b6e90d42" -Confirm:$false 
到目前为止,我已经获得了以下代码,它们将使用默认站点和功能包创建站点订阅。但是,我不知道如何在active directory中设置用户OU的路径

    //Create a default admin site for this tenant
    var site = new SPSite("https://contoso.com/", userToken);

    //Create the subscription and assign the default admin site to it.
    var sub = SPSiteSubscription.Create();
    sub.Add(site);

    //Get the feature pack and assign it to the subscription
    var featurePacks = SPSiteSubscriptionSettingsManager.Local.GetAllFeaturePacks();
    var pack = featurePacks.SingleOrDefault(x => x.Id == Guid.Parse("50976ac2-83bb-4110-946d-95b4b6e90d42"));
    SPSiteSubscriptionSettingsManager.Local.AssignFeaturePackToSiteSubscription(pack, sub);

有什么建议吗?

正如Rikard建议的那样,我为您使用了反射

设置SPSiteSubscriptionConfig
执行以下操作:

    if (this.m_UserAccountDirectoryPathSpecified)
    {
        SPSiteSubscriptionPropertyCollection adminProperties = this.m_SettingsManager.GetAdminProperties(this.m_ResolvedIdentity);
        if (!string.IsNullOrEmpty(this.UserAccountDirectoryPath))
        {
            adminProperties.SetValue("UserAccountDirectoryPath", this.UserAccountDirectoryPath);
        }
        else
        {
            adminProperties.Remove("UserAccountDirectoryPath");
        }
        adminProperties.Update();
    }
如您所见,它使用该方法来获取的管理员属性。 然后,它将继续使用值
“UserAccountDirectoryPath”
更新adminProperties集合中的
SPSiteSubscriptionProperty


你现在需要做的就是把它设置好,你就完成了。您可以使用类似的程序查看SharePoint Powershell Commandlet的代码。在本例中,您可以在Microsoft.SharePoint.PowerShell.SPCmdletSetSiteSubscriptionConfig中找到该代码

是否尝试使用PowerShell命令的反射查看它使用的代码类型?非常感谢,最后,我们的程序集需要同时支持SP2010和2013,所以我们决定无论如何都坚持使用powershell cmdlet。然而,我相信还有其他人会从中得到一些好处。再次感谢您出于安全考虑,我也检查了SP2013-相同的代码。在新版本中使用此代码同样安全:-)