Esempio n. 1
0
        public static ssa.SecureObject ToSecureObject(this legacySplxApi.UIElement uie)
        {
            ssa.SecureObject secureObject = new ssa.SecureObject
            {
                UId        = uie.Id,
                UniqueName = uie.UniqueName,
                IsEnabled  = true,  //prop doesn't exist in legacy objects
                ParentUId  = uie.ParentId
            };

            secureObject.Security.DaclAllowInherit    = uie.SecurityDescriptor.DaclInherit;
            secureObject.Security.SaclAllowInherit    = uie.SecurityDescriptor.SaclInherit;
            secureObject.Security.SaclAuditTypeFilter =
                (ssa.AuditType)Enum.Parse(typeof(ssa.AuditType), uie.SecurityDescriptor.SaclAuditTypeFilter.ToString());

            foreach (legacySplxApi.AccessControlEntryBase legacyAce in uie.SecurityDescriptor.Dacl)
            {
                secureObject.Security.Dacl.Add(legacyAce.ToNewAce());
            }

            foreach (legacySplxApi.AccessControlEntryBase legacyAce in uie.SecurityDescriptor.Sacl)
            {
                secureObject.Security.Sacl.Add((ssa.IAccessControlEntryAudit)legacyAce.ToNewAce());
            }

            return(secureObject);
        }
Esempio n. 2
0
        /// <summary>
        /// Selects and loads security for the given UniqueName into a SplxRecordManager
        /// </summary>
        /// <param name="uniqueName"></param>
        /// <returns>A loaded and resolved SplxRecordManager</returns>
        SplxSecureManagerBase GetSecureManagerSecurityRecurseUp(string userName, AceType aceType, string uniqueName, SecurityLoadParameters slp)
        {
            string          rootUniqueName = ContainerRootUniqueName;
            SecureContainer root           = new SecureContainer()
            {
                UniqueName = rootUniqueName
            };

            #region setup SecurityLoadParameters, load ExternalGroupInfo
            if (slp == null)
            {
                slp = new SecurityLoadParameters()
                {
                    ExternalGroupInfo = new ExternalGroupInfo(LdapRoot, true, GlobalExternalGroupsCsv),
                    User = this.GetSuplexUser(userName)
                }
            }
            ;

            ExternalGroupInfo egi =
                new ExternalGroupInfo(LdapRoot, true, GlobalExternalGroupsCsv);
            egi.BuildGroupsList(slp.User.Name);
            #endregion

            SecureContainer       ctrl    = root;
            SplxSecureManagerBase context = null;

            #region IsFileStore = true
            if (IsFileStore)
            {
                context = new SplxRecordManager()
                {
                    UniqueName = uniqueName
                };
                if (aceType == AceType.FileSystem)
                {
                    context = new SplxFileSystemManager()
                    {
                        UniqueName = uniqueName
                    }
                }
                ;

                splxApi.UIElement uie = _splxStore.UIElements.GetByUniqueNameRecursiveIgnoreCase(uniqueName);
                if (uie == null)
                {
                    throw new SecurityException($"Could not find security element [{uniqueName}] in the permissione configuration.");
                }


                ISecureControl curr      = context;
                IObjectModel   parentObj = uie.ParentObject;
                while (parentObj != null)
                {
                    SecureContainer par = new SecureContainer()
                    {
                        UniqueName = ((splxApi.UIElement)parentObj).UniqueName
                    };
                    par.Children.Add(curr);
                    curr = par;

                    parentObj = parentObj.ParentObject;
                }

                curr.Security.Load(_splxStore, slp);
            }
            #endregion
            #region IsFileStore = false
            else
            {
                DataSet ds = _da.GetDataSet("splx.splx_dal_sel_security_byuserbyuie_up",
                                            new System.Collections.sSortedList(
                                                "@UIE_UNIQUE_NAME", uniqueName,
                                                "@SPLX_USER_ID", slp.User.Id,
                                                "@EXTERNAL_GROUP_LIST", egi.GroupsList));

                _da.NameTablesFromCompositeSelect(ref ds);

                //todo, when suplex is ready
                //DataSet ds = _splxApi.GetSecurity( rootUniqueName, slp.User, slp.ExternalGroupInfo, future:recurseUp );

                DataTable acl  = ds.Tables["AclInfo"];
                DataRow[] rows = acl.Select(string.Format("UIE_UNIQUE_NAME = '{0}'", rootUniqueName));
                if (rows.Length > 0)
                {
                    rows = acl.Select(string.Format("UIE_PARENT_ID = '{0}'", rows[0]["SPLX_UI_ELEMENT_ID"]));
                }

                while (rows.Length > 0)
                {
                    string un = rows[0]["UIE_UNIQUE_NAME"].ToString();
                    if (un.StartsWith(ContainerUniqueNamePrefix))
                    {
                        context = new SplxRecordManager()
                        {
                            UniqueName = un
                        };
                        if (aceType == AceType.FileSystem)
                        {
                            context = new SplxFileSystemManager()
                            {
                                UniqueName = un
                            }
                        }
                        ;

                        ctrl.Children.Add(context);
                    }
                    else
                    {
                        SecureContainer child = new SecureContainer()
                        {
                            UniqueName = un
                        };
                        ctrl.Children.Add(child);
                        ctrl = child;
                    }

                    rows = acl.Select(string.Format("UIE_PARENT_ID = '{0}'", rows[0]["SPLX_UI_ELEMENT_ID"]));
                }

                root.Security.Load(ds, slp);
            }
            #endregion


            return(context);
        }