for example, i would like to implement something like the following. But get the error no overridable method exists and I do not know how to implement this logic. The role object need to be passed to the CanAdd and CanEdit. This works when using the CanGet because I pass in the object as part of the static method.
public override EmployeeEM Save(Role rl){
// origEmp is used to call pending changes with only props that have changed. if (!IsNew) // only retrieve this original if the record exists !origEmp =
EmployeeEM.GetEmployeeByEmpno(this.LocNo, this.EmpNo); if (IsNew && !CanAddObject(rl)) throw new System.Security.SecurityException( "User not authorized to add an Employee Record!"); else if (!CanEditObject(rl)) throw new System.Security.SecurityException( "User not authorized to update an Employee Record!"); return base.Save();}
thanks for your help, stuck on this.
I am doing it in order to make my bo's more efficient. It just so happens that the application I am working on would have over 30000 roles, a userID, and the Location and Division which would grant that user access to the site. Rather than hard code each role, or even populate this section I pass in the role requested through the role object. for example: userId 38322, location 8765 division 1. Since the userId roles was populated in the identity object in the same format I can simply send the userId, and the requested location and division and compare them to the allowed roles maintained in the identity object. I knew of know other way to do this. This way instead of 30000 entries in each "Canxxxx" method, I have very few. for example:
public static bool CanAddObject(Role rl){
bool result = false; if (Csla.ApplicationContext.User.IsInRole(rl.RockyRole + ":Worksite Manager"))}
I know it could be improved, but couldnt figure out a different solution. Then I had to figure out a way to make the role available through the insert and save methods. Once again, I had a difficult time with this, and finally made an extra property called currentRole (which i set in the ui, just before the update) and am able to check this property from within the bo. Any suggestions or alternate solutions are greatly appreciated.
Copyright (c) Marimer LLC