public void AddUserRole(string userAccount, string userRole) { try { manager.CreateUserRole(userAccount, userRole); } catch (Exception ex) { throw ex; } }
public static void CreateTestData(ConfigurationContext context) { UserRoleManager urm = new UserRoleManager("EntLibSecurity", context); DeleteTestData(context); byte[] pwd = SHA1Managed.Create().ComputeHash(ASCIIEncoding.ASCII.GetBytes("Password")); byte [] emptyPasswd = SHA1Managed.Create().ComputeHash(ASCIIEncoding.ASCII.GetBytes("")); urm.CreateUser("testuser", pwd); urm.CreateUser("bogususer", pwd); urm.CreateUser("emptyUser", emptyPasswd); urm.CreateRole("Admins"); urm.CreateRole("Managers"); urm.CreateRole("Users"); urm.CreateUserRole("testuser", "Users"); urm.CreateUserRole("testuser", "Managers"); }
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); }
private void CreateUserRoleDelegate(params object[] methodParams) { manager.CreateUserRole((string)methodParams[0], (string)methodParams[1]); }