예제 #1
0
        //gavdcodeend 06

        //gavdcodebegin 07
        static void SpCsCsomCreateGroupForSite(ClientContext spAdminCtx)
        {
            string[]            myOwners      = new string[] { "*****@*****.**" };
            GroupCreationParams myGroupParams = new GroupCreationParams(spAdminCtx);

            myGroupParams.Owners = myOwners;
            //GroupCreationParams
            Tenant myTenant = new Tenant(spAdminCtx);

            myTenant.CreateGroupForSite(
                ConfigurationManager.AppSettings["spBaseUrl"] +
                "/sites/NewSiteCollectionModernCsCsom01",
                "GroupForNewSiteCollectionModernCsCsom01",
                "GroupForNewSiteCollAlias",
                true,
                myGroupParams);

            spAdminCtx.ExecuteQuery();
        }
예제 #2
0
        /// <summary>
        /// Connect an Office 365 group to an existing SharePoint site collection
        /// </summary>
        /// <param name="tenant">The target tenant</param>
        /// <param name="siteUrl">Url to the site collection that needs to get connected to an Office 365 group</param>
        /// <param name="siteCollectionGroupifyInformation">Information that configures the "groupify" process</param>
        public static void GroupifySite(this Tenant tenant, string siteUrl, TeamSiteCollectionGroupifyInformation siteCollectionGroupifyInformation)
        {
            if (string.IsNullOrEmpty(siteUrl))
            {
                throw new ArgumentException("Missing value for siteUrl", "siteUrl");
            }

            if (siteCollectionGroupifyInformation == null)
            {
                throw new ArgumentException("Missing value for siteCollectionGroupifyInformation", "sitecollectionGroupifyInformation");
            }

            if (!string.IsNullOrEmpty(siteCollectionGroupifyInformation.Alias) && siteCollectionGroupifyInformation.Alias.Contains(" "))
            {
                throw new ArgumentException("Alias cannot contain spaces", "Alias");
            }

            if (string.IsNullOrEmpty(siteCollectionGroupifyInformation.DisplayName))
            {
                throw new ArgumentException("DisplayName is required", "DisplayName");
            }

            GroupCreationParams optionalParams = new GroupCreationParams(tenant.Context);

            if (!String.IsNullOrEmpty(siteCollectionGroupifyInformation.Description))
            {
                optionalParams.Description = siteCollectionGroupifyInformation.Description;
            }
            if (!String.IsNullOrEmpty(siteCollectionGroupifyInformation.Classification))
            {
                optionalParams.Classification = siteCollectionGroupifyInformation.Classification;
            }
            if (siteCollectionGroupifyInformation.KeepOldHomePage)
            {
                optionalParams.CreationOptions = new string[] { "SharePointKeepOldHomepage" };
            }

            tenant.CreateGroupForSite(siteUrl, siteCollectionGroupifyInformation.DisplayName, siteCollectionGroupifyInformation.Alias, siteCollectionGroupifyInformation.IsPublic, optionalParams);
            tenant.Context.ExecuteQueryRetry();
        }