コード例 #1
0
        protected override void OnCreated(object sender, NodeEventArgs e)
        {
            base.OnCreated(sender, e);

            using (new SystemAccount())
            {
                var parent = GroupMembershipObserver.GetFirstOrgUnitParent(e.SourceNode);
                if (parent != null)
                {
                    SecurityHandler.AddUsersToGroup(parent.Id, new[] { e.SourceNode.Id });
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// After creation adds this group to the nearest parent <see cref="OrganizationalUnit"/> in the security graph as a member.
        /// Do not use this method directly from your code.
        /// </summary>
        protected override void OnCreated(object sender, NodeEventArgs e)
        {
            base.OnCreated(sender, e);

            // insert this orgunit to the security graph
            using (new SystemAccount())
            {
                var parent = GroupMembershipObserver.GetFirstOrgUnitParent(this);
                if (parent != null)
                {
                    Providers.Instance.SecurityHandler.AddGroupsToGroup(parent.Id, new[] { this.Id });
                }
            }
        }
コード例 #3
0
ファイル: Group.cs プロジェクト: kuber123/sensenet
        /// <summary>
        /// After creation adds this group to the nearest parent <see cref="OrganizationalUnit"/> as a member.
        /// Do not use this method directly from your code.
        /// </summary>
        protected override void OnCreated(object sender, NodeEventArgs e)
        {
            base.OnCreated(sender, e);

            // insert this group to the security graph
            using (new SystemAccount())
            {
                var parent = GroupMembershipObserver.GetFirstOrgUnitParent(e.SourceNode);
                if (parent != null)
                {
                    SecurityHandler.AddGroupsToGroup(parent.Id, new[] { e.SourceNode.Id });
                }
            }

            var usersToAdd  = GetMemberUsers().Select(u => u.Id).ToArray();
            var groupsToAdd = GetMemberGroups().Select(g => g.Id).ToArray();

            if (usersToAdd.Length > 0 || groupsToAdd.Length > 0)
            {
                SecurityHandler.AddMembers(this.Id, usersToAdd, groupsToAdd);
            }
        }