コード例 #1
0
        protected override bool CheckAccessCore(OperationContext operationContext)
        {
            MyPrincipal pr = operationContext.ServiceSecurityContext.AuthorizationContext.Properties["Principal"] as MyPrincipal;

            string permitName    = null;
            string operationName = operationContext.IncomingMessageHeaders.Action.Substring(operationContext.IncomingMessageHeaders.Action.LastIndexOf("/", StringComparison.OrdinalIgnoreCase) + 1);

            switch (operationName)
            {
            case "DeleteFolder":
                permitName = "ManageFolder";
                break;

            case "DeleteFile":
                permitName = "ManageFile";
                break;

            case "CreateNewFile":
                permitName = "ManageFile";
                break;

            case "CreateNewFolder":
                permitName = "ManageFolder";
                break;

            default:
                permitName = "Read";
                break;
            }

            return(pr.IsInRole(permitName));
        }
コード例 #2
0
        protected override bool CheckAccessCore(OperationContext operationContext)
        {
            MyPrincipal pr = operationContext.ServiceSecurityContext.AuthorizationContext.Properties["Principal"] as MyPrincipal;

            return(pr.IsInRole("Read"));
        }