Exemplo n.º 1
0
        private void btExportXML_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                saveFileDialog1.Filter = "XML files|*.xml";

                if (this.saveFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var users        = MDSWrapper.UserSecurityPrincipalsGet();
                var groups       = MDSWrapper.GroupSecurityPrincipalsGet();
                var securityinfo = new SecurityInformation(users.Users, groups.Groups);


                MDSWrapper.SecurityPrincipalsExport(this.saveFileDialog1.FileName, securityinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Exemplo n.º 2
0
        public void SecurityPrincipalsImportTest()
        {
            var userToExport = MDSWrapper.UserSecurityPrincipalsGet(UserToExport);

            Assert.IsTrue(userToExport != null & userToExport.Users.Any(), "No security principals returned! Connection: " + MDSWrapper.Configuration.EndpointAddress);

            var fileName = String.Format(global::Common.Constants.StringFormatUserPrincipals, userToExport.Users.FirstOrDefault().Identifier.Id);

            MDSWrapper.SecurityPrincipalsExport(Path.Combine(folderToExport, fileName), new SecurityInformation(userToExport.Users));

            //switching to another environment
            var config = ConfigurationManager.AppSettings;

            MDSWrapper.Configuration = new ConfigValue("MDS Local 2", config.Get("Domain"), config.Get("UserName"), config.Get("Password"), new Uri("http://localhost:82/Service/service.svc"), BindingType.WSHttpBinding);
            MDSWrapper.SecurityPrincipalsImport(Path.Combine(folderToExport, fileName), PrincipalType.UserAccount, SecurityPrincipalsOptions.ExcludeAllPrivileges, false);
            var principals   = MDSWrapper.UserSecurityPrincipalsGet(UserToExport);
            var importedUser = principals.Users.FirstOrDefault();



            //checking if the principal exists in the 2nd environment
            Assert.IsTrue(importedUser.Identifier.Name == importedUser.Identifier.Name, "The user identifier does not match the expected result");
            Assert.IsTrue(importedUser.SecurityPrivilege.FunctionPrivileges.Count == 0, "The function privileges were not copied correctly");
            Assert.IsTrue(importedUser.SecurityPrivilege.ModelPrivileges.Count == 0, "The model privileges were not copied correctly");
            Assert.IsTrue(importedUser.SecurityPrivilege.HierarchyMemberPrivileges.Count == 0, "The hierarc privileges were not copied correctly");

            //Deleting the user
            MDSWrapper.SecurityPrincipalsDelete(principals, PrincipalType.UserAccount);
        }
Exemplo n.º 3
0
        public static void TestInitialize(TestContext context)
        {
            Initialize();

            //Setting the FUNCTION privileges for user
            var userToExport = MDSWrapper.UserSecurityPrincipalsGet(UserToExport).Users.FirstOrDefault();
        }
Exemplo n.º 4
0
        private void LoadSecurityPrincipals()
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                var users = MDSWrapper.UserSecurityPrincipalsGet();
                lstUsers.Items.Clear();
                foreach (User u in users.Users)
                {
                    this.lstUsers.Items.Add(new CustomUser(u));
                }

                //Note the security principals are server-level objects, not model specific
                var groups = MDSWrapper.GroupSecurityPrincipalsGet();
                lstGroups.Items.Clear();
                foreach (Group group in groups.Groups)
                {
                    this.lstGroups.Items.Add(new CustomGroup(group));
                }
            }
            catch (Exception ex)
            {
                statusStrip1.Text = ex.Message;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Exemplo n.º 5
0
        public void UserSecurityPrincipalsGet()
        {
            var model        = MDSWrapper.GetModelByName(modelName, global::Common.MDSService.ResultType.Identifiers);
            var userToExport = MDSWrapper.UserSecurityPrincipalsGet(UserToExport);

            Assert.IsTrue(userToExport != null);
            Assert.IsTrue(userToExport.Users.Count == 1);
            Assert.IsTrue(userToExport.Users.FirstOrDefault().Identifier.Name.Equals(UserToExport, StringComparison.InvariantCultureIgnoreCase));
        }
Exemplo n.º 6
0
        public void UserSecurityPrincipalsGetTest()
        {
            //var model = _wrapper.GetModelByName(modelName, global::Common.MDSService.ResultType.Identifiers);
            var users = MDSWrapper.UserSecurityPrincipalsGet();

            Trace.WriteLine("Users from instance:");
            foreach (User user in users.Users)
            {
                Trace.WriteLine(user.Identifier.Name);
            }
            Assert.IsNotNull(users.Users);
        }
Exemplo n.º 7
0
        public void SecurityPrincipalsExportTest()
        {
            var userToExport = MDSWrapper.UserSecurityPrincipalsGet(UserToExport);

            Assert.IsTrue(userToExport != null && userToExport.Users.Any(), "No security principals returned! Connection: " + MDSWrapper.Configuration.EndpointAddress);

            var fileName = String.Format(global::Common.Constants.StringFormatUserPrincipals, userToExport.Users.FirstOrDefault().Identifier.Id);

            MDSWrapper.SecurityPrincipalsExport(Path.Combine(folderToExport, fileName), new SecurityInformation(userToExport.Users));

            Assert.IsTrue(File.Exists(Path.Combine(folderToExport, fileName)));
            //File.Delete(Path.Combine(folderToExport, fileName));
        }
Exemplo n.º 8
0
        public void ExportSecurityPrivilegesTest()
        {
            var model = MDSWrapper.GetModelByName(modelName, global::Common.MDSService.ResultType.Identifiers);

            var userToExport = MDSWrapper.UserSecurityPrincipalsGet(UserToExport);

            Assert.IsTrue(userToExport != null && userToExport.Users.Any(), "No security principals returned! Connection: " + MDSWrapper.Configuration.EndpointAddress);

            var fileName = String.Format(global::Common.Constants.StringFormatUserPrivileges, userToExport.Users.FirstOrDefault().Identifier.Id);

            MDSWrapper.SecurityPrivilegesExport(model.Identifier, folderToExport, fileName, userToExport.Users.FirstOrDefault());

            Assert.IsTrue(File.Exists(Path.Combine(folderToExport, fileName)));
            //File.Delete(Path.Combine(folderToExport, fileName));
        }
Exemplo n.º 9
0
        public static void TestInitialize(TestContext context)
        {
            Initialize();

            //Setting the FUNCTION privileges for user
            var userToExport = MDSWrapper.UserSecurityPrincipalsGet(UserToExport).Users.FirstOrDefault();
            var functionPriv = new List <FunctionPrivilege> {
                new FunctionPrivilege {
                    Function = FunctionalArea.SystemAdministration, IsAuthorized = true, PrincipalId = userToExport.Identifier, PrincipalType = PrincipalType.UserAccount
                },
                new FunctionPrivilege {
                    Function = FunctionalArea.Versions, IsAuthorized = true, PrincipalId = userToExport.Identifier, PrincipalType = PrincipalType.UserAccount
                }
            };

            var securityPrivilege = userToExport.SecurityPrivilege;

            securityPrivilege.FunctionPrivileges = functionPriv;
            var result = MDSWrapper.SecurityPrivilegesCreate(securityPrivilege);
        }
Exemplo n.º 10
0
        private void RefreshPermissionsList(object sender)
        {
            try
            {
                DataGridView ruleDataGrid = null;
                if (sender == cbConnection.ComboBox)
                {
                    ruleDataGrid = dgRules;
                }

                if (sender == cbConnection2.ComboBox)
                {
                    ruleDataGrid = dgRules2;
                }

                Cursor.Current = Cursors.WaitCursor;
                var dataSet = MDSDataUtils.NewPermissionDataTable();

                var users = MDSWrapper.UserSecurityPrincipalsGet();

                foreach (var user in users.Users)
                {
                    foreach (var modelPrivilege in user.SecurityPrivilege.ModelPrivileges)
                    {
                        MDSDataUtils.NewPermissionDataRow(dataSet, user.Identifier, modelPrivilege);
                    }
                    foreach (var hierarchPrivilege in user.SecurityPrivilege.HierarchyMemberPrivileges)
                    {
                        MDSDataUtils.NewPermissionDataRow(dataSet, user.Identifier, hierarchPrivilege);
                    }
                }

                var groups = MDSWrapper.GroupSecurityPrincipalsGet();

                foreach (var group in groups.Groups)
                {
                    foreach (var modelPrivilege in group.SecurityPrivilege.ModelPrivileges)
                    {
                        MDSDataUtils.NewPermissionDataRow(dataSet, group.Identifier, modelPrivilege);
                    }
                    foreach (var hierarchPrivilege in group.SecurityPrivilege.HierarchyMemberPrivileges)
                    {
                        MDSDataUtils.NewPermissionDataRow(dataSet, group.Identifier, hierarchPrivilege);
                    }
                }

                ruleDataGrid.DataSource = dataSet;
                //hiding the column ID
                ruleDataGrid.Columns[0].Visible = false;

                btExport.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }