当前位置: 首页>>代码示例>>C#>>正文


C# Tenant.GetSitePropertiesByUrl方法代码示例

本文整理汇总了C#中Tenant.GetSitePropertiesByUrl方法的典型用法代码示例。如果您正苦于以下问题:C# Tenant.GetSitePropertiesByUrl方法的具体用法?C# Tenant.GetSitePropertiesByUrl怎么用?C# Tenant.GetSitePropertiesByUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tenant的用法示例。


在下文中一共展示了Tenant.GetSitePropertiesByUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnUpdateSiteCollectionStatus_Click

        protected void btnUpdateSiteCollectionStatus_Click(object sender, EventArgs e)
        {
            string siteUrl = sitecollections.SelectedValue;
            using (var ctx = GetAdminContext())
            {
                // get site collections.
                Tenant tenant = new Tenant(ctx);
                SiteProperties siteProp = tenant.GetSitePropertiesByUrl(siteUrl, true);
                ctx.Load(siteProp);
                ctx.ExecuteQuery();

                switch (rblSharingOptions.SelectedValue)
                {
                    case "Disabled":
                        siteProp.SharingCapability = SharingCapabilities.Disabled;
                        lblStatus.Text = "External sharing is for authenticated and guest users.";
                        break;
                    case "ExternalUserAndGuestSharing":
                        siteProp.SharingCapability = SharingCapabilities.ExternalUserAndGuestSharing;
                        lblStatus.Text = "External sharing is for authenticated and guest users.";
                        break;
                    case "ExternalUserSharingOnly":
                        siteProp.SharingCapability = SharingCapabilities.ExternalUserSharingOnly;
                        lblStatus.Text = "External sharing is for authenticated and guest users.";
                        break;
                }
                // Update based on applied setting
                siteProp.Update();
                ctx.ExecuteQuery();
                lblStatus.Text = string.Format("Sharing status updated for site collection at URL: {0}", siteUrl);
            }
        }
开发者ID:tandis,项目名称:PnP,代码行数:32,代码来源:ExternalSettingsAtSiteCollectionLevel.aspx.cs

示例2: EnableExternalSharing

        public void EnableExternalSharing(Tenant tenant, Site site)
        {
            ClientContext context = (ClientContext)site.Context;
            tenant.SetSiteProperties(site.Url, sharingCapability: SharingCapabilities.ExternalUserSharingOnly);

            SiteProperties siteProps = tenant.GetSitePropertiesByUrl(site.Url, false);
            context.Load(tenant);
            context.Load(siteProps);
            context.ExecuteQuery();
        }
开发者ID:comblox,项目名称:PnP-Partner-Pack,代码行数:10,代码来源:SiteCollectionProvisioningJobHandler.cs

示例3: GetSharingCapabilitiesTenant

 /// <summary>
 /// Get the external sharing settings for the provided site. Only works in Office 365 Multi-Tenant
 /// </summary>
 /// <param name="web">Tenant administration web</param>
 /// <param name="siteUrl">Site to get the sharing capabilities from</param>
 /// <returns>Sharing capabilities of the site collection</returns>
 public static string GetSharingCapabilitiesTenant(this Web web, Uri siteUrl)
 {
     Tenant tenant = new Tenant(web.Context);
     SiteProperties site = tenant.GetSitePropertiesByUrl(siteUrl.OriginalString, true);
     web.Context.Load(site);
     web.Context.ExecuteQuery();
     return site.SharingCapability.ToString();
 }
开发者ID:nitewolfgtr,项目名称:PnP,代码行数:14,代码来源:SecurityExtensions.cs

示例4: SetSiteSharing

        /// <summary>
        /// Sets the Site Collection External Sharing Setting using the SharePoint Tenant API
        /// </summary>
        /// <param name="adminCC"></param>
        /// <param name="siteCollectionURl"></param>
        /// <param name="shareSettings"></param>
        public static void SetSiteSharing(ClientContext adminCC, string siteCollectionURl, SharingCapabilities shareSettings)
        {
            var _tenantAdmin = new Tenant(adminCC);
            SiteProperties _siteprops = _tenantAdmin.GetSitePropertiesByUrl(siteCollectionURl, true);
            adminCC.Load(_tenantAdmin);
            adminCC.Load(_siteprops);
            adminCC.ExecuteQuery();

            SharingCapabilities _tenantSharing = _tenantAdmin.SharingCapability;
            var _currentShareSettings = _siteprops.SharingCapability;
            bool _isUpdatable = false;

            if(_tenantSharing == SharingCapabilities.Disabled)
            {
                Console.WriteLine("Sharing is currently disabled in your tenant! I am unable to work on it.");
            }
            else
            {  
                if(shareSettings == SharingCapabilities.Disabled)
                { _isUpdatable = true; }
                else if(shareSettings == SharingCapabilities.ExternalUserSharingOnly)
                {
                    _isUpdatable = true;   
                }
                else if (shareSettings == SharingCapabilities.ExternalUserAndGuestSharing)
                {
                    if (_tenantSharing == SharingCapabilities.ExternalUserAndGuestSharing)
                    {
                        _isUpdatable = true;
                    }
                    else
                    {
                        Console.WriteLine("ExternalUserAndGuestSharing is currently disabled in your tenant! I am unable to work on it.");
                    }
                }
            }
            if (_currentShareSettings != shareSettings && _isUpdatable)
            {
                _siteprops.SharingCapability = shareSettings;
                _siteprops.Update();
                adminCC.ExecuteQuery();
                Console.WriteLine("Set Sharing on site {0} to {1}.", siteCollectionURl, shareSettings);
            }
        }
开发者ID:AaronSaikovski,项目名称:PnP,代码行数:50,代码来源:Program.cs

示例5: SetSiteLockStateTest

        public void SetSiteLockStateTest()
        {
            try
            {
                using (var tenantContext = TestCommon.CreateTenantClientContext())
                {
                    tenantContext.RequestTimeout = Timeout.Infinite;

                    var tenant = new Tenant(tenantContext);
                    string devSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"];
                    string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);

                    Console.WriteLine("SetSiteLockStateTest: step 1");
                    if (!tenant.SiteExists(siteToCreateUrl))
                    {
                        siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                        Console.WriteLine("SetSiteLockStateTest: step 1.1");
                        var siteExists = tenant.SiteExists(siteToCreateUrl);
                        Console.WriteLine("SetSiteLockStateTest: step 1.2");
                        Assert.IsTrue(siteExists, "Site collection creation failed");
                    }

                    Console.WriteLine("SetSiteLockStateTest: step 2");
                    // Set Lockstate NoAccess test
                    tenant.SetSiteLockState(siteToCreateUrl, SiteLockState.NoAccess, true);

                    Console.WriteLine("SetSiteLockStateTest: step 2.1");
                    var siteProperties = tenant.GetSitePropertiesByUrl(siteToCreateUrl, true);
                    Console.WriteLine("SetSiteLockStateTest: step 2.1");
                    tenantContext.Load(siteProperties);
                    tenantContext.ExecuteQueryRetry();
                    Assert.IsTrue(siteProperties.LockState == SiteLockState.NoAccess.ToString(), "LockState wasn't set to NoAccess");

                    // Set Lockstate NoAccess test
                    Console.WriteLine("SetSiteLockStateTest: step 3");
                    tenant.SetSiteLockState(siteToCreateUrl, SiteLockState.Unlock, true);
                    Console.WriteLine("SetSiteLockStateTest: step 3.1");
                    var siteProperties2 = tenant.GetSitePropertiesByUrl(siteToCreateUrl, true);
                    Console.WriteLine("SetSiteLockStateTest: step 3.2");
                    tenantContext.Load(siteProperties2);
                    tenantContext.ExecuteQueryRetry();
                    Assert.IsTrue(siteProperties2.LockState == SiteLockState.Unlock.ToString(), "LockState wasn't set to UnLock");

                    //Delete site collection, also
                    Console.WriteLine("SetSiteLockStateTest: step 4");
                    tenant.DeleteSiteCollection(siteToCreateUrl, false);
                    Console.WriteLine("SetSiteLockStateTest: step 4.1");
                    var siteExists2 = tenant.SiteExists(siteToCreateUrl);
                    Console.WriteLine("SetSiteLockStateTest: step 4.2");
                    Assert.IsFalse(siteExists2, "Site collection deletion, including from recycle bin, failed");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:58,代码来源:TenantExtensionsTests.cs

示例6: SetSiteLockStateTest

        public void SetSiteLockStateTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var tenant = new Tenant(tenantContext);
                string devSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"];
                string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);

                if (!tenant.SiteExists(siteToCreateUrl))
                {
                    siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                    var siteExists = tenant.SiteExists(siteToCreateUrl);
                    Assert.IsTrue(siteExists, "Site collection creation failed");
                }

                // Set Lockstate NoAccess test
                tenant.SetSiteLockState(siteToCreateUrl, SiteLockState.NoAccess, true);
                var siteProperties = tenant.GetSitePropertiesByUrl(siteToCreateUrl, true);
                tenantContext.Load(siteProperties);
                tenantContext.ExecuteQueryRetry();
                Assert.IsTrue(siteProperties.LockState == SiteLockState.NoAccess.ToString(), "LockState wasn't set to NoAccess");

                // Set Lockstate NoAccess test
                tenant.SetSiteLockState(siteToCreateUrl, SiteLockState.Unlock, true);
                var siteProperties2 = tenant.GetSitePropertiesByUrl(siteToCreateUrl, true);
                tenantContext.Load(siteProperties2);
                tenantContext.ExecuteQueryRetry();
                Assert.IsTrue(siteProperties2.LockState == SiteLockState.Unlock.ToString(), "LockState wasn't set to UnLock");

                //Delete site collection, also
                tenant.DeleteSiteCollection(siteToCreateUrl, false);
                var siteExists2 = tenant.SiteExists(siteToCreateUrl);
                Assert.IsFalse(siteExists2, "Site collection deletion, including from recycle bin, failed");
            }
        }
开发者ID:xaviayala,项目名称:Birchman,代码行数:35,代码来源:TenantExtensionsTests.cs

示例7: SetExternalSharing

        /// <summary>
        /// 
        /// </summary>
        /// <param name="siteInfo"></param>
        public override void SetExternalSharing(SiteRequestInformation siteInfo)
        {
            UsingContext(ctx =>
            {
                try
                {
                    Tenant _tenant = new Tenant(ctx);
                    SiteProperties _siteProps = _tenant.GetSitePropertiesByUrl(siteInfo.Url, false);
                    ctx.Load(_tenant);
                    ctx.Load(_siteProps);
                    ctx.ExecuteQuery();
                    bool _shouldBeUpdated = false;

                    var _tenantSharingCapability = _tenant.SharingCapability;
                    var _siteSharingCapability = _siteProps.SharingCapability;
                    var _targetSharingCapability = SharingCapabilities.Disabled;

                    if(siteInfo.EnableExternalSharing && _tenantSharingCapability != SharingCapabilities.Disabled)
                    {
                        _targetSharingCapability = SharingCapabilities.ExternalUserSharingOnly;
                        _shouldBeUpdated = true;
                    }
                    if (_siteSharingCapability != _targetSharingCapability && _shouldBeUpdated)
                    {
                        _siteProps.SharingCapability = _targetSharingCapability;
                        _siteProps.Update();
                        ctx.ExecuteQuery();
                        Log.Info("Provisioning.Common.Office365SiteProvisioningService.SetExternalSharing", PCResources.ExternalSharing_Successfull, siteInfo.Url);
                    }
                   
                }
                catch(Exception _ex)
                {
                    Log.Info("Provisioning.Common.Office365SiteProvisioningService.SetExternalSharing", PCResources.ExternalSharing_Exception, siteInfo.Url, _ex);
                }
             
            });
        }
开发者ID:ipbhattarai,项目名称:PnP,代码行数:42,代码来源:Office365SiteProvisioningService.cs

示例8: isSiteExternalSharingEnabled

        /// <summary>
        /// 
        /// </summary>
        /// <param name="siteUrl"></param>
        public virtual bool isSiteExternalSharingEnabled(string siteUrl)
        {
            ConfigManager _manager = new ConfigManager();
            var _tenantAdminUrl = _manager.GetAppSettingsKey("TenantAdminUrl");
            var _returnResult = false;

            AbstractSiteProvisioningService _siteService = new Office365SiteProvisioningService();
            _siteService.Authentication = new AppOnlyAuthenticationTenant();
            _siteService.Authentication.TenantAdminUrl = _tenantAdminUrl;

            _siteService.UsingContext(ctx =>
            {
                try
                {
                    Tenant _tenant = new Tenant(ctx);
                    SiteProperties _siteProps = _tenant.GetSitePropertiesByUrl(siteUrl, false);
                    ctx.Load(_tenant);
                    ctx.Load(_siteProps);
                    ctx.ExecuteQuery();


                    var _tenantSharingCapability = _tenant.SharingCapability;
                    var _siteSharingCapability = _siteProps.SharingCapability;

                    if (_tenantSharingCapability != SharingCapabilities.Disabled)
                    {
                        if (_siteSharingCapability != SharingCapabilities.Disabled)
                        {
                            // Enabled
                            _returnResult = true;
                        }
                        else
                        {
                            // Disabled
                            _returnResult = false;
                        }
                    }
                    else
                    {
                        // Disabled
                        _returnResult = false;
                    }

                }
                catch (Exception _ex)
                {
                    Log.Warning("AbstractSiteProvisioningService.IsSiteExternalSharingEnabled",
                        PCResources.SiteExternalSharing_Enabled_Error_Message,
                        siteUrl,
                        _ex);
                }

            });

            return _returnResult;
        }
开发者ID:Calisto1980,项目名称:PnP,代码行数:60,代码来源:AbstractSiteProvisioningService.cs

示例9: sitecollections_SelectedIndexChanged

        protected void sitecollections_SelectedIndexChanged(object sender, EventArgs e)
        {
            string siteUrl = sitecollections.SelectedValue;

            using (var ctx = GetAdminContext())
            {
                // get site collections.
                Tenant tenant = new Tenant(ctx);
                SiteProperties siteProp = tenant.GetSitePropertiesByUrl(siteUrl, true);
                ctx.Load(siteProp);
                ctx.ExecuteQuery();

                switch (siteProp.SharingCapability)
                {
                    case SharingCapabilities.Disabled:
                        lblStatus.Text = "External sharing is disabled.";
                        rblSharingOptions.SelectedValue = "Disabled";
                        break;
                    case SharingCapabilities.ExternalUserSharingOnly:
                        lblStatus.Text = "External sharing is for authenticated users.";
                        rblSharingOptions.SelectedValue = "ExternalUserSharingOnly";
                        break;
                    case SharingCapabilities.ExternalUserAndGuestSharing:
                        lblStatus.Text = "External sharing is for authenticated and guest users.";
                        rblSharingOptions.SelectedValue = "ExternalUserAndGuestSharing";
                        break;
                    default:
                        break;
                }
                lblStatus.Text = string.Format("Sharing status resolved for site collection at URL: {0}", siteUrl);
            }
        }
开发者ID:tandis,项目名称:PnP,代码行数:32,代码来源:ExternalSettingsAtSiteCollectionLevel.aspx.cs

示例10: SiteExistsInTenant

        /// <summary>
        /// Checks if a site collection exists, relies on tenant admin API
        /// </summary>
        /// <param name="web">Site to be processed - can be root web or sub site</param>
        /// <param name="siteUrl">URL to the site collection</param>
        /// <returns>True if existing, false if not</returns>
        public static bool SiteExistsInTenant(this Web web, string siteUrl)
        {
            try
            {
                //Get the site name
                Tenant tenant = new Tenant(web.Context);
                var properties = tenant.GetSitePropertiesByUrl(siteUrl, false);
                web.Context.Load(properties);
                web.Context.ExecuteQuery();

                // Will cause an exception if site URL is not there. Not optimal, but the way it works.
                return true;
            }
            catch (Exception ex)
            {
                if (ex is Microsoft.SharePoint.Client.ServerException && (ex.Message.IndexOf("Unable to access site") != -1 || ex.Message.IndexOf("Cannot get site") != -1))
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
        }
开发者ID:BNATENSTEDT,项目名称:PnP,代码行数:31,代码来源:SiteExtensions.cs

示例11: CheckIfSiteExistsInTenant

        /// <summary>
        /// Returns if a site collection is in a particular status. If the url contains a sub site then returns true is the sub site exists, false if not. 
        /// Status is irrelevant for sub sites
        /// </summary>
        /// <param name="web">Tenant admin web</param>
        /// <param name="siteUrl">Url to the site collection</param>
        /// <param name="status">Status to check (Active, Creating, Recycled)</param>
        /// <returns>True if in status, false if not in status</returns>
        public static bool CheckIfSiteExistsInTenant(this Web web, string siteUrl, string status)
        {
            bool ret = false;
            //Get the site name
            var url = new Uri(siteUrl);
            var UrlDomain = string.Format("{0}://{1}", url.Scheme, url.Host);
            int idx = url.PathAndQuery.Substring(1).IndexOf("/") + 2;
            var UrlPath = url.PathAndQuery.Substring(0, idx);
            var Name = url.PathAndQuery.Substring(idx);
            var index = Name.IndexOf('/');
            Tenant tenant = new Tenant(web.Context);

            //Judge whether this site collection is existing or not
            if (index == -1)
            {
                var properties = tenant.GetSitePropertiesByUrl(siteUrl, false);
                web.Context.Load(properties);
                web.Context.ExecuteQuery();
                ret = properties.Status.Equals(status, StringComparison.OrdinalIgnoreCase);
            }
            //Judge whether this sub web site is existing or not
            else
            {
                var site = tenant.GetSiteByUrl(string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}{1}{2}", UrlDomain, UrlPath, Name.Split("/".ToCharArray())[0]));
                var subweb = site.OpenWeb(Name.Substring(index + 1));
                web.Context.Load(subweb, w => w.Title);
                web.Context.ExecuteQuery();
                ret = true;
            }
            return ret;
        }
开发者ID:BNATENSTEDT,项目名称:PnP,代码行数:39,代码来源:SiteExtensions.cs

示例12: LoadSiteStatus

 /// <summary>
 /// Load the latest site collection status from SharePoint
 /// </summary>
 /// <param name="e">Timer job event arguments</param>
 /// <param name="tenant">The tenant object</param>
 /// <param name="site">The site object</param>
 /// <param name="properties">The site properties object</param>
 private void LoadSiteStatus(TimerJobRunEventArgs e, out Tenant tenant, out Site site, out SiteProperties properties)
 {
     var tenantClientContext = e.TenantClientContext;
     Log.Info(base.Name, TimerJobsResources.SynchJob_GetSiteStatus, e.Url);
     tenant = new Tenant(tenantClientContext);
     site = tenant.GetSiteByUrl(e.Url);
     properties = tenant.GetSitePropertiesByUrl(e.Url, includeDetail: false);
     tenantClientContext.Load(tenant,
         t => t.SharingCapability);
     tenantClientContext.Load(site,
         s => s.RootWeb.Title,
         s => s.RootWeb.Description,
         s => s.RootWeb.Language,
         s => s.RootWeb.Created,
         s => s.Id);
     tenantClientContext.Load(properties,
         s => s.StorageMaximumLevel,
         s => s.StorageWarningLevel,
         s => s.UserCodeMaximumLevel,
         s => s.UserCodeWarningLevel,
         s => s.TimeZoneId,
         s => s.SharingCapability);
     tenantClientContext.ExecuteQueryRetry();
 }
开发者ID:Calisto1980,项目名称:PnP,代码行数:31,代码来源:SynchronizationJob.cs

示例13: GetTenantInformation

        /// <summary>
        /// the following code uses tenant admin rights to get information from the Tenant API.
        /// this requires a tenatn administrator to trust the app
        /// </summary>
        /// <param name="siteCollectionUrl">The Url of the site collection for information</param>
        private void GetTenantInformation(string siteCollectionUrl)
        {
            string tenantName = ConfigurationManager.AppSettings["TenantName"];
            Uri tenantAdminUri = new Uri(string.Format("https://{0}-admin.sharepoint.com", tenantName));
            string adminRealm = TokenHelper.GetRealmFromTargetUrl(tenantAdminUri);
            string adminToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, tenantAdminUri.Authority, adminRealm).AccessToken;

            //tenant app-only context to admin site collection
            using (var clientContext = TokenHelper.GetClientContextWithAccessToken(tenantAdminUri.ToString(), adminToken))
            {
                var tenant = new Tenant(clientContext);
                clientContext.Load(tenant);
                clientContext.ExecuteQuery();

                SiteProperties properties = tenant.GetSitePropertiesByUrl(siteCollectionUrl, true);
                clientContext.Load(properties);
                clientContext.ExecuteQuery();

                lblLastModified.Text = properties.LastContentModifiedDate.ToString();
                lblWebsCount.Text = properties.WebsCount.ToString();
            }
        }
开发者ID:tandis,项目名称:PnP,代码行数:27,代码来源:Default.aspx.cs

示例14: ValidateExternalUsersTimerJob_TimerJobRun

		private void ValidateExternalUsersTimerJob_TimerJobRun(object sender, TimerJobRunEventArgs e)
		{
			Console.WriteLine("Starting job");
			var web = e.SiteClientContext.Web;
			Tenant tenant = new Tenant(e.TenantClientContext);

			var siteAdmins = e.SiteClientContext.LoadQuery(web.SiteUsers.Include(u => u.Email).Where(u => u.IsSiteAdmin));
			e.SiteClientContext.ExecuteQueryRetry();

			List<string> adminEmails = new List<string>();

			foreach (var siteAdmin in siteAdmins)
			{
				adminEmails.Add(siteAdmin.Email);
			}

			SiteProperties p = tenant.GetSitePropertiesByUrl(e.SiteClientContext.Url, true);
			var sharingCapability = p.EnsureProperty(s => s.SharingCapability);
			if (sharingCapability != Microsoft.Online.SharePoint.TenantManagement.SharingCapabilities.Disabled)
			{
				DateTime checkDate = DateTime.Now;
				var lastCheckDate = e.WebClientContext.Web.GetPropertyBagValueString(PNPCHECKDATEPROPERTYBAGKEY, string.Empty);
				if (lastCheckDate == string.Empty)
				{
					// new site. Temporary set the check date to less than one Month
					checkDate = checkDate.AddMonths(-2);
				}
				else
				{

					if (!DateTime.TryParse(lastCheckDate, out checkDate))
					{
						// Something went wrong with trying to parse the date in the propertybag. Do the check anyway.
						checkDate = checkDate.AddMonths(-2);
					}
				}
				if (checkDate.AddMonths(1) < DateTime.Now)
				{
					e.SiteClientContext.Web.EnsureProperty(w => w.Url);
					e.WebClientContext.Web.EnsureProperty(w => w.Url);
					EmailProperties mailProps = new EmailProperties();
					mailProps.Subject = "Review required: external users with access to your site";
					StringBuilder bodyBuilder = new StringBuilder();

					bodyBuilder.AppendFormat("<html><head>{0}</head><body style=\"font-family:sans-serif\">", CSSSTYLE);
					bodyBuilder.AppendFormat("<p>Your site with address {0} has one or more external users registered. Please review the following list and take appropriate action if such access is not wanted anymore for a user.</p>", e.SiteClientContext.Web.Url);
					bodyBuilder.Append("<table class=\"tg\"><tr><th>Name</th><th>Invited by</th><th>Created</th><th>Invited As</th><th>Accepted As</th></tr>");

					var externalusers = e.TenantClientContext.Web.GetExternalUsersForSiteTenant(new Uri(e.WebClientContext.Web.Url));
					if (externalusers.Any())
					{
						foreach (var externalUser in externalusers)
						{
							bodyBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td></tr>", externalUser.DisplayName, externalUser.InvitedBy, externalUser.WhenCreated, externalUser.InvitedAs, externalUser.AcceptedAs);
						}
						bodyBuilder.Append("</table></body></html>");
						mailProps.Body = bodyBuilder.ToString();
						mailProps.To = adminEmails.ToArray();

						Utility.SendEmail(e.SiteClientContext, mailProps);
						e.SiteClientContext.ExecuteQueryRetry();
					}
					e.WebClientContext.Web.SetPropertyBagValue(PNPCHECKDATEPROPERTYBAGKEY, DateTime.Now.ToString());
				}

			}

			Console.WriteLine("Ending job");

		}
开发者ID:modulexcite,项目名称:PnP-Partner-Pack,代码行数:70,代码来源:ValidateExternalUsersTimerJob.cs

示例15: SetExternalSharing

        /// <summary>
        /// Used to set External Sharing
        /// </summary>
        /// <param name="siteInfo"></param>
        public override void SetExternalSharing(SiteInformation siteInfo)
        {
            UsingContext(ctx =>
            {
                try
                {
                    Stopwatch _timespan = Stopwatch.StartNew();

                    Tenant _tenant = new Tenant(ctx);

                    //_tenant.SetSiteProperties(siteInfo.Url, null, null, SharingCapabilities.ExternalUserSharingOnly, null, null, null, null);
                    SiteProperties _siteProps = _tenant.GetSitePropertiesByUrl(siteInfo.Url, false);
                    ctx.Load(_tenant);
                    ctx.Load(_siteProps);
                    ctx.ExecuteQuery();
                    
                    var _tenantSharingCapability = _tenant.SharingCapability;
                    var _siteSharingCapability = _siteProps.SharingCapability;
                    var _targetSharingCapability = SharingCapabilities.Disabled;

                    if(!siteInfo.EnableExternalSharing && _tenantSharingCapability != SharingCapabilities.Disabled)
                    {
                        _targetSharingCapability = SharingCapabilities.Disabled;                        

                        _siteProps.SharingCapability = _targetSharingCapability;
                        _siteProps.Update();
                        ctx.ExecuteQuery();
                        Log.Info("Provisioning.Common.Office365SiteProvisioningService.SetExternalSharing", PCResources.ExternalSharing_Successful, siteInfo.Url);
                    }
                    if (siteInfo.EnableExternalSharing && _tenantSharingCapability != SharingCapabilities.Disabled)
                    {
                        _targetSharingCapability = SharingCapabilities.ExternalUserSharingOnly;                        

                        _siteProps.SharingCapability = _targetSharingCapability;
                        _siteProps.Update();
                        ctx.ExecuteQuery();
                        Log.Info("Provisioning.Common.Office365SiteProvisioningService.SetExternalSharing", PCResources.ExternalSharing_Successful, siteInfo.Url);
                    }

                    _timespan.Stop();
                    Log.TraceApi("SharePoint", "Office365SiteProvisioningService.SetExternalSharing", _timespan.Elapsed, "SiteUrl={0}", siteInfo.Url);
       
                   
                }
                catch(ServerException _ex)
                {
                    Log.Info("Provisioning.Common.Office365SiteProvisioningService.SetExternalSharing", PCResources.ExternalSharing_Exception, siteInfo.Url, _ex);
     
                }
                catch(Exception _ex)
                {
                    Log.Info("Provisioning.Common.Office365SiteProvisioningService.SetExternalSharing", PCResources.ExternalSharing_Exception, siteInfo.Url, _ex);
                }
             
            });
        }
开发者ID:iozag,项目名称:PnP,代码行数:60,代码来源:Office365SiteProvisioningService.cs


注:本文中的Tenant.GetSitePropertiesByUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。