Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4101194
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:39:55+00:00 2026-05-20T20:39:55+00:00

I have a class that implements IAuthorizationPolicy. I set up a custom Principal object

  • 0

I have a class that implements IAuthorizationPolicy. I set up a custom Principal object based on the logged in user which has all of my base level roles (I have also done this using claims). Now I would like to change the roles that a particular principal has depending on a key value passed in as a message parameter.

The problem I am having is that the request message cannot be read in the authorization policy class because I don’t have access to write the message back to the request context. I can copy and read the message in a ServiceAuthorizationManager derived class using an override of the CheckAccess method. However, I have to ensure that the GetAuthorizationPolicies method has already been called prior to doing that.

I am looking for suggestions on how I can vary the roles on a principal, based on whether or not the message contains a particular parameter. Basically, when the Evaluate method id called on the policy I want to do something like this:

string myObjectId = null;

if (!messageCopy.IsEmpty)
{
    System.Xml.XmlDictionaryReader xdr = messageCopy.GetReaderAtBodyContents();
    xdr.ReadToDecendant("objectId");
    if (xdr.Read())
    {
        myObjectId = xdr.ReadContentAsString();
    }
    xdr.Close();
}
messageCopy.Close();

ClaimSet claims = (myObjectId != null) ?
    MapClaims(identity, myObjectId) : MapClaims(identity);

DefaultPrincipal principal = new DefaultPrincipal(identity, claims);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:39:55+00:00Added an answer on May 20, 2026 at 8:39 pm

    After an entire day of attempted failures, I gave up on trying to read the message body and used an easier method, adding a SOAP message header. When calling the service I now perform the following:

    using (new OperationContextScope((IContextChannel)myService)) {
        OperationContext.Current.OutgoingMessageHeaders.Add(
            MessageHeader.CreateHeader("objectId", "http://tempuri.org/", "object value"));
        myService.BeginMyOperation(parm, callback, state);
    }
    

    Then in my service authorization policy’s Evaluate method I do this:

    int index = OperationContext.Current.IncomingMessageHeaders.FindHeader(
        "objectId", "http://tempuri.org/");
    
    string myObjectId = (index < 0) ? null : 
        OperationContext.Current.IncomingMessageHeaders.GetHeader<string>(index);
    
    ClaimSet claims = (myObjectId != null) ?
        MapClaims(identity, myObjectId) : MapClaims(identity);
    
    DefaultPrincipal principal = new DefaultPrincipal(identity, claims);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that implements an interface, which is made available for plugins.
I have a class that implements ISelectionListener. I want to determine when the user
I have an abstract class, AbsClass that implements an interface, IClass . IClass has
I have class X that implements Queue. I want to pass Class X's Object
I have a class MyDoublyIterator<E> that implements the Iterator<E> interface. Also, it has a
I have a class that implements IDisposable because it has a private member field
I have a class that implements a linked list. The class has a find()
I have a class that implements java.io.Serializable interface.So all the variables in that class
I have a C++ class that implements reference-counting and I want all users of
I have a class that implements the IDisposable interface. I am using a webclient

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.