Ejemplo n.º 1
0
        /// <summary>
        /// Sets a site to Unlock access or NoAccess. This operation may occur immediately, but the site lock may take a short while before it goes into effect.
        /// </summary>
        /// <param name="tenant">A tenant object pointing to the context of a Tenant Administration site (i.e. https://[tenant]-admin.sharepoint.com)</param>
        /// <param name="siteFullUrl">The target site to change the lock state.</param>
        /// <param name="lockState">The target state the site should be changed to.</param>
        /// <param name="wait">If true, processing will halt until the site collection lock state has been implemented</param>
        /// <param name="timeoutFunction">An optional function that will be called while waiting for the site to be created. If set will override the wait variable. Return true to cancel the wait loop.</param>
        public static void SetSiteLockState(this Tenant tenant, string siteFullUrl, SiteLockState lockState, bool wait = false, Func <TenantOperationMessage, bool> timeoutFunction = null)
        {
            var siteProps = tenant.GetSitePropertiesByUrl(siteFullUrl, true);

            tenant.Context.Load(siteProps);
            tenant.Context.ExecuteQueryRetry();

            Log.Info(CoreResources.TenantExtensions_SetLockState, siteProps.LockState, lockState);

            if (siteProps.LockState != lockState.ToString())
            {
                siteProps.LockState = lockState.ToString();
                SpoOperation op = siteProps.Update();
                tenant.Context.Load(op, i => i.IsComplete, i => i.PollingInterval);
                tenant.Context.ExecuteQueryRetry();
                if (timeoutFunction != null)
                {
                    wait = true;
                }
                if (wait)
                {
                    WaitForIsComplete(tenant, op, timeoutFunction, TenantOperationMessage.SettingSiteLockState);
                }
            }
        }
Ejemplo n.º 2
0
        // This is separate from SetSiteProperties because it is not available from the v15 assemblies.

        /// <summary>
        /// Sets a site to Unlock access or NoAccess. This operation may occur immediately, but the site lock may take a short while before it goes into effect.
        /// </summary>
        /// <param name="tenant">A tenant object pointing to the context of a Tenant Administration site (i.e. https://[tenant]-admin.sharepoint.com)</param>
        /// <param name="siteFullUrl">The target site to change the lock state.</param>
        /// <param name="lockState">The target state the site should be changed to.</param>
        public static void SetSiteLockState(this Tenant tenant, string siteFullUrl, SiteLockState lockState)
        {
            var siteProps = tenant.GetSitePropertiesByUrl(siteFullUrl, true);

            tenant.Context.Load(siteProps);
            tenant.Context.ExecuteQuery();

            LoggingUtility.Internal.TraceInformation(0, CoreResources.TenantExtensions_SetLockState, siteProps.LockState, lockState);

            if (siteProps.LockState != lockState.ToString())
            {
                siteProps.LockState = lockState.ToString();
                siteProps.Update();
                tenant.Context.ExecuteQuery();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets a site to Unlock access or NoAccess. This operation may occur immediately, but the site lock may take a short while before it goes into effect.
        /// </summary>
        /// <param name="tenant">A tenant object pointing to the context of a Tenant Administration site (i.e. https://[tenant]-admin.sharepoint.com)</param>
        /// <param name="siteFullUrl">The target site to change the lock state.</param>
        /// <param name="lockState">The target state the site should be changed to.</param>
        /// <param name="wait">If true, processing will halt until the site collection lock state has been implemented</param>
        public static void SetSiteLockState(this Tenant tenant, string siteFullUrl, SiteLockState lockState, bool wait = false)
        {
            var siteProps = tenant.GetSitePropertiesByUrl(siteFullUrl, true);

            tenant.Context.Load(siteProps);
            tenant.Context.ExecuteQuery();

            LoggingUtility.Internal.TraceInformation(0, CoreResources.TenantExtensions_SetLockState, siteProps.LockState, lockState);

            if (siteProps.LockState != lockState.ToString())
            {
                siteProps.LockState = lockState.ToString();
                SpoOperation op = siteProps.Update();
                tenant.Context.Load(op, i => i.IsComplete, i => i.PollingInterval);
                tenant.Context.ExecuteQuery();

                if (wait)
                {
                    WaitForIsComplete(tenant, op);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Sets a site to Unlock access or NoAccess. This operation may occur immediately, but the site lock may take a short while before it goes into effect.
        /// </summary>
        /// <param name="tenant">A tenant object pointing to the context of a Tenant Administration site (i.e. https://[tenant]-admin.sharepoint.com)</param>
        /// <param name="siteFullUrl">The target site to change the lock state.</param>
        /// <param name="lockState">The target state the site should be changed to.</param>
        /// <param name="wait">If true, processing will halt until the site collection lock state has been implemented</param>      
        public static void SetSiteLockState(this Tenant tenant, string siteFullUrl, SiteLockState lockState, bool wait = false)
        {
            var siteProps = tenant.GetSitePropertiesByUrl(siteFullUrl, true);
            tenant.Context.Load(siteProps);
            tenant.Context.ExecuteQueryRetry();

            Log.Info(CoreResources.TenantExtensions_SetLockState, siteProps.LockState, lockState);

            if (siteProps.LockState != lockState.ToString())
            {
                siteProps.LockState = lockState.ToString();
                SpoOperation op = siteProps.Update();
                tenant.Context.Load(op, i => i.IsComplete, i => i.PollingInterval);
                tenant.Context.ExecuteQueryRetry();

                if (wait)
                {
                    WaitForIsComplete(tenant, op);
                }

            }
        }