Re: Custom Principal Permission (non-CodeAccessPermission derived) not working

From: Olivier Haddad (olivier_haddad_at_hotmail.com)
Date: 06/30/03

  • Next message: J-P Meunier: "Re: xml Signature and XmlDsigXPathTransform"
    Date: Mon, 30 Jun 2003 00:59:43 -0700
    
    

    What I mean by "declarative permission is ignored" is that
    no xml metadata
    is added to the method.

    I want to create a permission class that does not derive
    from
    CodeAccessPermission.

    According to MSDN:

    (see
    ms-
    help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cp
    concreatingoth
    ercustompermissions.htm}

    "You must do the following in order to use such a
    permission:

    -Implement IPermission.

    -Implement ISecurityEncodable to add support for XML
    encoding and decoding.

    -Support declarative security by defining an attribute.

    -Demand your custom permission within a library.

    Note that security policy does not have to be updated to
    include non-code
    access permissions. "

    I did all four steps but the compiler still doesn't call
    the
    "CreatePermission" method of my SecurityAttribute-derived
    class.

    To be sure of it, I called Console.WriteLine in
    CreatePermission and did not
    see my trace string during compilation.

    Thanks,

    Olivier

    >-----Original Message-----
    >What do you mean with declarative permission is ignored?
    If you don't add
    >your permission to the security policy, it's likely that
    your assembly won't
    >have this permission and fail on a Demand. Can you
    explain what are you
    >trying to do using declarative security and how do you
    grant your permission
    >without modifying the security policy?
    >
    >Thanks,
    >Marcelo
    >
    >"Olivier Haddad" <olivier.hadad@emblaze.com> wrote in
    message
    >news:OOFFO8wODHA.3700@tk2msftngp13.phx.gbl...
    >> I wrote a simple class implementing IPermission and a
    corresponding
    >> attribute class deriving from SecurityAttribute.
    >>
    >> My permission class does not derive from
    CodeAccessPermission as I am not
    >> interested in a stack walk (like PrincipalPermission).
    >>
    >> I didn't add the assembly to the Security Policy as
    MSDN states that it is
    >> not needed for non-CAS permissions.
    >>
    >> Imperative permission works fine, but declarative
    permission is ignored.
    >> Checking the compiled file with ILDasm and Permview
    revealed that no XML
    >> permission metadata was added.
    >>
    >> How do I get my Security Attribute derivated class to
    work?
    >>
    >> The MSDN documentation only gives proper examples for
    CodeAccessSecurity
    >> derived classes.
    >>
    >>
    >>
    >
    >
    >.
    >


  • Next message: J-P Meunier: "Re: xml Signature and XmlDsigXPathTransform"

    Relevant Pages