Is there a technical reason why a PrincipalPermission can’t be placed on a service contract interface? It only works on the class implementing the contract or directly on the class methods.
This doesn’t work.
[ServiceContract]
public interface IMyService
{
[PrincipalPermission(SecurityAction.Demand, Role="Admin")]
[OperationContract]
void MyFunction(string str);
}
But it works if I place the attribute on the matching method in the class implementing IMyService.
The role is checked at runtime, using the attributes put on the implementing method, not the attributes put on the interface the method implements. More generally in .NET there is not direct relation between custom attributes put on a method and custom attributes put on the corresponding interface method, if any.