/// <summary> /// delete role /// </summary> /// <param name="roleName">role name</param> public static void DeleteRole(string roleName) { UserRoleManager roleManager = new UserRoleManager(); try { roleManager.CreateConnection(); roleManager.Connection.Open(GetServerConnectionSetup()); Role role = roleManager.GetRole(roleName); if (role != null) { roleManager.DeleteRole(role.Guid, roleName); } } catch { throw; } finally { if (roleManager != null) { roleManager.Connection.Close(); roleManager.Connection.Dispose(); roleManager.DeleteConnection(); roleManager.Connection = null; roleManager = null; } } }
private void DeleteRole() { base.ServiceBroker.Service.ServiceObjects[0].Properties.InitResultTable(); DataTable results = base.ServiceBroker.ServicePackage.ResultTable; UserRoleManager urmServer = this.ServiceBroker.K2Connection.GetConnection <UserRoleManager>(); using (urmServer.Connection) { string roleName = base.GetStringProperty(Constants.SOProperties.Role.RoleName, true); Role role = urmServer.GetRole(roleName); if (role == null) { throw new ApplicationException(Resources.RoleNotExists); } else { urmServer.DeleteRole(role.Guid, role.Name); urmServer.Connection.Close(); } } }
private void DeleteRole() { base.ServiceBroker.Service.ServiceObjects[0].Properties.InitResultTable(); DataTable results = base.ServiceBroker.ServicePackage.ResultTable; UserRoleManager urmServer = new UserRoleManager(); using (urmServer.CreateConnection()) { urmServer.Connection.Open(base.BaseAPIConnectionString); string roleName = base.GetStringProperty(Constants.SOProperties.Role.RoleName, true); Role role = urmServer.GetRole(roleName); if (role == null) { throw new ApplicationException(Constants.ErrorMessages.RoleNotExists); } else { urmServer.DeleteRole(role.Guid, role.Name); urmServer.Connection.Close(); } } }
public void CreateAndDeleteRole() { manager.CreateRole(roleName); DataSet ds = SelectRole(roleName); Assert.AreEqual(1, ds.Tables[0].Rows.Count); Assert.AreEqual(roleName, ds.Tables[0].Rows[0]["RoleName"]); // delete the row manager.DeleteRole(roleName); ds = SelectIdentity(); Assert.AreEqual(0, ds.Tables[0].Rows.Count); }
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 { } }
private void DeleteRoleDelegate(params object[] methodParams) { manager.DeleteRole((string)methodParams[0]); }
private void DeleteRole() { ServiceObject serviceObject = this.Service.ServiceObjects[0]; serviceObject.Properties.InitResultTable(); UserRoleManager urmServer = new UserRoleManager(); using (urmServer.CreateConnection()) { urmServer.Connection.Open(WFMServerConnectionString); string roleName = serviceObject.Properties[Constants.Properties.RoleName].Value as string; Guid roleGUID = new Guid(serviceObject.Properties[Constants.Properties.RoleGuid].Value as string); Role role = urmServer.GetRole(roleName); if (role == null) { throw new ApplicationException(Constants.ErrorText.RoleNotExist); } else { urmServer.DeleteRole(roleGUID, roleName); urmServer.Connection.Close(); } } }
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 { } }