.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

IAuthorizationPolicy CurrentPrincipal

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :.NET Framework
I have a custom AuthorizationPolicy in WCF Service


class CustomAuthorizationPolicy : IAuthorizationPolicy


string id = Guid.NewGuid().ToString();

string IAuthorizationComponent.Id


get { return this.id; }


ClaimSet IAuthorizationPolicy.Issuer


get { return ClaimSet.System; }


bool IAuthorizationPolicy.Evaluate(EvaluationContext context, ref object state)


object obj;

if (!context.Properties.TryGetValue("Identities", out obj))


context.Properties["Principal"] = new GuestPrincipal(new GenericIdentity("Guest"));

View Complete Post

More Related Resource Links

WebServiceHost2Factory is forcing Thread.CurrentPrincipal to RoleProviderPrincipal instead of my cus

Hi gang, I've been working through various samples to try and piece together a solution for SAML token-based authentication for ASP.Net and WCF RESTful services...  some of the samples I've been referencing: http://custombasicauth.codeplex.com/Wikipage http://www.leastprivilege.com/SecuringWCFDataServicesUsingWIF.aspx http://weblogs.asp.net/cibrax/archive/2010/02/17/a-good-way-to-handle-claim-based-security-in-restful-services.aspx etc... I've been battling my way through each roadblock, and I'm so close I can taste it.  The latest block that's got me is this: If I use the regular WebServiceHostFactory, the custom authorization policies are applied and Thread.CurrentPrincipal ends up taking the value that my HttpModule set for HttpContext.Current.User...   but...  if I use the WebServiceHost2Factory (i.e. from the REST Starter Kit) to gain the auto help endpoint, etc...,  then the auth policies aren't applied, and the Thread.CurrentPrincipal ends up being an instance of RoleProviderPrincipal in no way related to the ClaimsPrincipal I set in the HttpModule..   :-( Any thoughts, ideas how to get the WebServiceHost2Factory to play nice with the custom / overridden principal? Thanks, Tyler  

Weird Thread.CurrentPrincipal behavior

msdn has a code sample illustrating the use of SetPrincipalPolicy. I copy the code and the output below:

using System;
using System.Security.Principal;
using System.Threading;

class ADPrincipal
    static void Main(string[] args)
        // Create a new thread with a generic principal.
        Thread t = new Thread(new ThreadStart(PrintPrincipalInformation));

        // Set the principal policy to WindowsPrincipal.
        AppDomain currentDomain = AppDomain.CurrentDomain;
        // The new thread will have a Windows principal representing the
        // current user.
        t = new Thread(new ThreadStart(PrintPrincipalInformation));

Remoting Issue - Authentication Type changes from Kerberos to NTLM in Thread.CurrentPrincipal.Identi


Am facing followingproblem, Authentication Type changes from Kerberos to NTLM in Thread.CurrentPrincipal.Identity where as the user name comes properly while calling the method of service2 through remoting from service1.

Actually the problem scenario is as follows, from client am making calls to service1 and from the service1 am making the call to another service2 where the problem occurs.

             Kerberos                              NTML
Client ----------------> Server1 -------------------------> another service2
         remoting call                      remoting call

But When I made the remoting call from the client directly to service2, am getting the security type as Kerberos properly.

Please advise.

Am running out of time, looking for you valuable comments...!!!



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend