Exemplo n.º 1
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.º 2
0
        private void btImportUR_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (this.openFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                MDSWrapper.SecurityPrincipalsImport(openFileDialog1.FileName, PrincipalType.UserAccount, SecurityPrincipalsOptions.ExcludeAllPrivileges, false);
            }
            catch (Exception ex)
            {
                statusStrip1.Text = ex.Message;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }