Exemple #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;
            }
        }
Exemple #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);
        }
Exemple #3
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));
        }
Exemple #4
0
        private void btExportGroups_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (cbModel.SelectedItem != null)
                {
                    if (folderBrowserDialog1.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    //SecurityPrincipals are instance-level
                    //var modelId = this.cbModel.SelectedItem as Identifier;
                    var path = folderBrowserDialog1.SelectedPath;

                    MDSWrapper.SecurityPrincipalsExport(Path.Combine(path, String.Format(Constants.StringFormatGroupPrincipals, MDSWrapper.Configuration.ConfigName.Replace(' ', '_'))), PrincipalType.Group);

                    if (MessageBox.Show("Group principals successfully exported to " + path.Replace("\\\\", "\\") + "\r\nDo you want to open the destination folder ?", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        Process.Start("explorer.exe", path);
                    }
                }
                else
                {
                    MessageBox.Show("Please select a model first");
                }
            }
            catch (Exception ex)
            {
                statusStrip1.Text = ex.Message;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }