コード例 #1
0
        public void AddAndRemoveUserRoles()
        {
            byte[] password = ASCIIEncoding.ASCII.GetBytes("zab123");

            manager.CreateUser(userName, password);
            manager.CreateRole(roleName);
            manager.CreateRole(roleName2);

            manager.CreateUserRole(userName, roleName);
            manager.CreateUserRole(userName, roleName2);

            DataSet ds = SelectUserRoles(userName);

            Assert.AreEqual(2, ds.Tables[0].Rows.Count);
            Assert.AreEqual(roleName, ds.Tables[0].Rows[0]["RoleName"]);
            Assert.AreEqual(roleName2, ds.Tables[0].Rows[1]["RoleName"]);

            // delete the rows
            manager.DeleteUserRole(userName, roleName);
            manager.DeleteUserRole(userName, roleName2);
            ds = SelectUserRoles(userName);
            Assert.AreEqual(0, ds.Tables[0].Rows.Count);

            manager.DeleteRole(roleName);
            manager.DeleteRole(roleName2);
            manager.DeleteUser(userName);
        }
コード例 #2
0
 private async void DeleteUserRole_Click(object sender, RoutedEventArgs e)
 {
     if (UserRoleIdWillBeDeleted.Text != "")
     {
         string id = UserRoleIdWillBeDeleted.Text;
         await UserRoleManager.DeleteUserRole(id, UserRoles);
     }
 }
コード例 #3
0
 public void DeleteUserRole(string userAccount, string userRole)
 {
     try
     {
         manager.DeleteUserRole(userAccount, userRole);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public int DeleteUserRole(int userRoleID)
 {
     try
     {
         return(UserRoleManager.DeleteUserRole(userRoleID));
     }
     catch
     {
         return(0);
     }
 }
コード例 #5
0
        private async void DeleteUserRole_Click(object sender, RoutedEventArgs e)
        {
            await UserRoleManager.DeleteUserRole((String)((Button)sender).Tag, UserRoles);

            Frame.Navigate(typeof(ManageUserRolePage));
        }
コード例 #6
0
ファイル: TestDataSetup.cs プロジェクト: bnantz/NCS-V1-1
        public static void DeleteTestData(ConfigurationContext context)
        {
            Data.Database db = DatabaseFactory.CreateDatabase("EntLibSecurity");
            DBCommandWrapper cmd = db.GetSqlStringCommandWrapper("delete Profiles");
            db.ExecuteNonQuery(cmd);

            UserRoleManager urm = new UserRoleManager("EntLibSecurity", context);

            try
            {
                urm.DeleteUserRole("testuser", "Users");
            }
            catch
            {
            }
            try
            {
                urm.DeleteUserRole("testuser", "Managers");
            }
            catch
            {
            }

            try
            {
                urm.DeleteRole("Admins");
            }
            catch
            {
            }
            try
            {
                urm.DeleteRole("Managers");
            }
            catch
            {
            }
            try
            {
                urm.DeleteRole("Users");
            }
            catch
            {
            }

            try
            {
                urm.DeleteUser("testuser");
            try {urm.DeleteUser("emptyUser");} catch{}
            }
            catch
            {
            }
            try
            {
                urm.DeleteUser("bogususer");
            }
            catch
            {
            }
            try
            {
                urm.DeleteUser("emptyUser");
            }
            catch
            {
            }
        }
コード例 #7
0
 private void DeleteUserRoleDelegate(params object[] methodParams)
 {
     manager.DeleteUserRole((string)methodParams[0], (string)methodParams[1]);
 }
コード例 #8
0
        public static void DeleteTestData(ConfigurationContext context)
        {
            Data.Database    db  = DatabaseFactory.CreateDatabase("EntLibSecurity");
            DBCommandWrapper cmd = db.GetSqlStringCommandWrapper("delete Profiles");

            db.ExecuteNonQuery(cmd);

            UserRoleManager urm = new UserRoleManager("EntLibSecurity", context);

            try
            {
                urm.DeleteUserRole("testuser", "Users");
            }
            catch
            {
            }
            try
            {
                urm.DeleteUserRole("testuser", "Managers");
            }
            catch
            {
            }

            try
            {
                urm.DeleteRole("Admins");
            }
            catch
            {
            }
            try
            {
                urm.DeleteRole("Managers");
            }
            catch
            {
            }
            try
            {
                urm.DeleteRole("Users");
            }
            catch
            {
            }

            try
            {
                urm.DeleteUser("testuser");
                try { urm.DeleteUser("emptyUser"); } catch {}
            }
            catch
            {
            }
            try
            {
                urm.DeleteUser("bogususer");
            }
            catch
            {
            }
            try
            {
                urm.DeleteUser("emptyUser");
            }
            catch
            {
            }
        }