Configuring a sharepoint site subscriptions user account directory path with the object model

Viewed 2404

I'm working on multi tenant provisioning in sharepoint and I'm having trouble figuring out if you can set the user account directory path for a site subscription using the sharepoint object model. I know this can be done through powershell with the following cmdlet.

    $sub = New-SPSiteSubscription 
    $sub | Set-SPSiteSubscriptionConfig -UserAccountDirectoryPath "OU=AlpineBikeStore,OU=Hosting,DC=contoso,DC=com" -FeaturePack "50976ac2-83bb-4110-946d-95b4b6e90d42" -Confirm:$false 

So far I've got the following code that will create a site subscription with a default site and feature pack. However, I can't figure out how to set the path to the users OU in active directory.

    //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);

Any suggestions?

1 Answers
Related