Exemplo n.º 1
0
        /// <summary>
        /// Get web record by URL
        /// </summary>
        /// <param name="url">The web URL</param>
        /// <returns>Web information entity</returns>
        public WebInformation GetWeb(string url)
        {
            var tmp = new WebInformation()
            {
                Url = url,
            };
            var existed = Webs.FirstOrDefault(w =>
                                              w.Name == tmp.Name &&
                                              w.UrlDomain == tmp.UrlDomain &&
                                              w.UrlPath == tmp.UrlPath);

            return(existed);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update HasBroadAccess to 1 for both of the site collection and the current web record if any large security group permission assignment was found on the current web
        /// </summary>
        /// <param name="dbSiteRecord">The site collection record</param>
        /// <param name="dbWebRecord">The current web record</param>
        /// <param name="e">The timer job run event arguments</param>
        public override void Preprocess(SiteInformation dbSiteRecord, WebInformation dbWebRecord, TimerJobRunEventArgs e)
        {
            var tenant = new Tenant(e.TenantClientContext);
            var site   = tenant.GetSiteByUrl(e.Url);
            var web    = e.Url == dbWebRecord.SiteUrl
                ? site.RootWeb
                : site.OpenWeb(e.Url.Substring(dbWebRecord.Name.IndexOf('/') + 1));

            // load additional properties could be used to optimize the permission checking process
            e.TenantClientContext.Load(web,
                                       w => w.HasUniqueRoleAssignments,
                                       w => w.Url,
                                       w => w.ServerRelativeUrl,
                                       w => w.ParentWeb.ServerRelativeUrl);

            var assignments = new List <PermissionAssignment>();
            var entries     = from groupLoginName in BroadAccessGroups.Keys
                              select new PermissionAssignment
            {
                Url        = e.Url,
                Group      = groupLoginName,
                Permission = web.GetUserEffectivePermissions(groupLoginName)
            };

            assignments.AddRange(entries);
            e.TenantClientContext.ExecuteQuery();

            var incompliantAssignments = assignments.Where(
                p => p.Permission.Value != null && (
                    p.Permission.Value.Has(PermissionKind.ViewPages) ||
                    p.Permission.Value.Has(PermissionKind.ViewListItems)));

            dbWebRecord.HasBroadAccess = incompliantAssignments.Any();
            if (dbWebRecord.HasBroadAccess)
            {
                dbWebRecord.BroadAccessGroups = string.Join(";",
                                                            (from a in incompliantAssignments select a.Group).ToArray());
                dbSiteRecord.HasBroadAccess = true;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Get web record by URL
 /// </summary>
 /// <param name="url">The web URL</param>
 /// <returns>Web information entity</returns>
 public WebInformation GetWeb(string url)
 {
     var tmp = new WebInformation()
     {
         Url = url,
     };
     var existed = Webs.FirstOrDefault(w =>
         w.Name == tmp.Name &&
         w.UrlDomain == tmp.UrlDomain &&
         w.UrlPath == tmp.UrlPath);
     return existed;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Update HasBroadAccess to 1 for both of the site collection and the current web record if any large security group permission assignment was found on the current web
        /// </summary>
        /// <param name="dbSiteRecord">The site collection record</param>
        /// <param name="dbWebRecord">The current web record</param>
        /// <param name="e">The timer job run event arguments</param>
        public override void Preprocess(SiteInformation dbSiteRecord, WebInformation dbWebRecord, TimerJobRunEventArgs e)
        {
            var tenant = new Tenant(e.TenantClientContext);
            var site = tenant.GetSiteByUrl(e.Url);
            var web = e.Url == dbWebRecord.SiteUrl
                ? site.RootWeb
                : site.OpenWeb(e.Url.Substring(dbWebRecord.Name.IndexOf('/') + 1));
            // load additional properties could be used to optimize the permission checking process
            e.TenantClientContext.Load(web,
                w => w.HasUniqueRoleAssignments,
                w => w.Url,
                w => w.ServerRelativeUrl,
                w => w.ParentWeb.ServerRelativeUrl);

            var assignments = new List<PermissionAssignment>();
            var entries = from groupLoginName in BroadAccessGroups.Keys
                select new PermissionAssignment
                {
                    Url = e.Url,
                    Group = groupLoginName,
                    Permission = web.GetUserEffectivePermissions(groupLoginName)
                };
            assignments.AddRange(entries);
            e.TenantClientContext.ExecuteQuery();

            var incompliantAssignments = assignments.Where(
                p => p.Permission.Value != null && (
                    p.Permission.Value.Has(PermissionKind.ViewPages) ||
                    p.Permission.Value.Has(PermissionKind.ViewListItems)));

            dbWebRecord.HasBroadAccess = incompliantAssignments.Any();
            if (dbWebRecord.HasBroadAccess)
            {
                dbWebRecord.BroadAccessGroups = string.Join(";",
                    (from a in incompliantAssignments select a.Group).ToArray());
                dbSiteRecord.HasBroadAccess = true;
            }
        }
Exemplo n.º 5
0
 public virtual void Preprocess(SiteInformation siteCollection, WebInformation web, TimerJobRunEventArgs e)
 {
 }