|
| 1 | +--- |
| 2 | +title: Groupify - CSOM development |
| 3 | +description: Client side object model development for groupify operation |
| 4 | +ms.date: 4/16/2018 |
| 5 | +--- |
| 6 | + |
| 7 | +# Groupify: CSOM development |
| 8 | + |
| 9 | +> [!IMPORTANT] |
| 10 | +> The option to connect an Office 365 group to an existing site is **not** yet available and will be released during Q2 of calendar year 2018. |
| 11 | +
|
| 12 | +The SharePoint client-side object model (CSOM) provides access to the SharePoint object model from code that is running locally or on a different server than SharePoint. |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | +Before you get started, make sure that you're familiar with the following: |
| 16 | +- [Using the Client Object Model](https://msdn.microsoft.com/en-us/library/ff798388.aspx) |
| 17 | +- [Common Programming Tasks in the Managed Client Object Model](https://msdn.microsoft.com/en-us/library/ee537013.aspx) |
| 18 | + |
| 19 | +You will also need to reference the [Microsoft.SharePointOnline.CSOM](https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM/) NuGet package (version 16.1.6906.1200 or later). |
| 20 | + |
| 21 | +## CSOM code example |
| 22 | + |
| 23 | +The following example shows how to create a __Microsoft.Online.SharePoint.TenantAdministration.Tenant__ object and call the __GetAllTenantThemes__ method to return a list of themes. |
| 24 | + |
| 25 | +> [!NOTE] |
| 26 | +> * The URL used to create the context object includes the _-admin_ suffix, because **TenantAdministration** methods work with the admin site. |
| 27 | +> * Create a __Tenant__ instance with the [Tenant constructor](https://msdn.microsoft.com/en-us/library/dn174852.aspx), and then call the methods on that instance. |
| 28 | +
|
| 29 | +```C# |
| 30 | +using System.Security; |
| 31 | +using Microsoft.SharePoint.Client; |
| 32 | +using Microsoft.Online.SharePoint.TenantAdministration; |
| 33 | +using Microsoft.Online.SharePoint.TenantManagement; |
| 34 | + |
| 35 | +... |
| 36 | + |
| 37 | +ClientContext ctx = new ClientContext("https://contoso-admin.sharepoint.com/"); |
| 38 | +var pwd = "mypassword"; |
| 39 | +var passWord = new SecureString(); |
| 40 | +foreach (char c in pwd.ToCharArray()) passWord.AppendChar(c); |
| 41 | +ctx. Credentials = new SharePointOnlineCredentials( "[email protected]", passWord); |
| 42 | +Tenant tenant = new Tenant(ctx); |
| 43 | +tenant.CreateGroupForSite("https://contoso.sharepoint.com/sites/team-site", "display-name-for-group", "alias-for-group", true); |
| 44 | +``` |
| 45 | + |
| 46 | + |
| 47 | +## Methods in Microsoft.Online.SharePoint.TenantAdministration.Tenant class |
| 48 | + |
| 49 | +Use the following methods to customize the set of available themes for a SharePoint tenant administration site. You can add a new custom theme, update an existing theme, or delete a theme, and you can retrieve a specific theme or all themes. You can also hide or restore the default themes that come with SharePoint. |
| 50 | + |
| 51 | +### CreateGroupForSite method |
| 52 | + |
| 53 | +Create a new Office 365 group and attach it to an existing site. After this succeeds for a given site, calling it again with the same site will throw an Exception. |
| 54 | + |
| 55 | +__Namespace:__ Microsoft.Online.SharePoint.TenantAdministration.Tenant<br/> |
| 56 | +__Return type:__ void |
| 57 | + |
| 58 | +#### Parameters |
| 59 | + |
| 60 | +|Parameter | Type |Description | |
| 61 | +|----------- |------ |-------------| |
| 62 | +| siteUrl | string | URL of the site to Groupify | |
| 63 | +| displayName | string | Display Name group to create | |
| 64 | +| alias | string | Alias of the new group to create | |
| 65 | +| isPublic | bool | Whether the group is public or private | |
| 66 | +| optionalParams | GroupCreationParams | An optional set of creation parameters for the Group | |
| 67 | + |
| 68 | + |
| 69 | +__type:__ Microsoft.Online.SharePoint.TenantAdministration.GroupCreationParams<br/> |
| 70 | + |
| 71 | +|Property | Type |Description | |
| 72 | +|----------- |------ |-------------| |
| 73 | +| Description | string | Gets and sets the group description. | |
| 74 | +| Owners | string[] | Gets and sets the group owners. These should be the principal names of the users. | |
| 75 | +| CreationOptions | string[] | Gets and sets the group's creation options. | |
| 76 | +| Classification | string | Gets and sets the group's data classification. | |
| 77 | + |
0 commit comments