I would like to create an attribute-based validator that goes a few steps beyond what I saw in the examples. This will basically prevent the execution of methods or other functions.
Keep in mind that I need to use AzMan , because in this case I do not have access to Active Directory.
Here is some kind of pseudo code of what I'm looking for:
[AttributeUsage( AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true, Inherited = true )]
public class PermissionsValidatorAttribute : Attribute
{
public PermissionsValidatorAttribute(PermissionEnumeration permission){...}
public bool UserCanCreateAndEdit(){...}
public bool UserCanDelete(){...}
public bool UserCanUpload(){...}
}
Here is a sample of the sample / pen to be decorated. The method will not be executed at all if PermissionValidator.UserCanDelete () does not return true from the place where it was executed:
public class DoStuffNeedingPermissions
{
[PermissionValidator(PermissionEnumeration.MustHaveDeletePermission)]
public void DeleteSomething(){...}
}
, , . , . , DeleteSomething() , .
, , POC. . , , , -, . , , DoStuffNeedingPermissions. !