Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
        private void btExportGroupPrivileges_Click(object sender, EventArgs e)
        {
            MDSWrapper mdsWrapper = null;

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (this.cbModel.SelectedItem != null)
                {
                    if (this.folderBrowserDialog1.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    var modelId = this.cbModel.SelectedItem as Identifier;
                    var path    = this.folderBrowserDialog1.SelectedPath;

                    if (lstGroups.SelectedItem != null)
                    {
                        var fileName = String.Format(Constants.StringFormatGroupPrivileges, (lstGroups.SelectedItem as Group).Identifier.InternalId);
                        MDSWrapper.SecurityPrivilegesExport(modelId, path, fileName, lstGroups.SelectedItem as 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;
                if (mdsWrapper != null)
                {
                    mdsWrapper.Dispose();
                }
            }
        }
Ejemplo n.º 3
0
        private void btUserPrivilegesExport_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (this.cbModel.SelectedItem == null)
                {
                    MessageBox.Show("Please select a model first.");
                    return;
                }
                if (lstUsers.SelectedItem == null)
                {
                    MessageBox.Show("Please select a user.");
                    return;
                }

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

                var modelId = this.cbModel.SelectedItem as Identifier;
                var path    = this.folderBrowserDialog1.SelectedPath;

                if (lstUsers.SelectedItem == null)
                {
                    return;
                }

                var user = (CustomUser)lstUsers.SelectedItem;
                MDSWrapper.SecurityPrivilegesExport(modelId, path, String.Format(Constants.StringFormatUserPrivileges, user.Identifier.InternalId), user);

                if (MessageBox.Show("User privileges for " + user.Identifier.Name + " 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);
                }
            }
            catch (Exception ex)
            {
                statusStrip1.Text = ex.Message;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 4
0
        public void ImportUserSecurityPrivilegesFunctionPrivilegesTest()
        {
            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(null, folderToExport, fileName, userToExport.Users.FirstOrDefault());

            //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.SecurityPrivilegesImport(Path.Combine(folderToExport, fileName), SecurityPrivilegesOptions.FunctionPrivileges, false);

            var importedUser = MDSWrapper.UserSecurityPrincipalsGet(UserToExport).Users.FirstOrDefault();

            var functPriv = importedUser.SecurityPrivilege.FunctionPrivileges;

            foreach (var item in functPriv)
            {
                Trace.WriteLine(String.Format("Function privilege {0} = {1}", item.Function, item.IsAuthorized));
            }
            //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 == 2, "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(importedUser);


            Assert.IsTrue(File.Exists(Path.Combine(folderToExport, fileName)));
        }