.NET Framework Bookmark and Share   
 index > ASMX Web Services and XML Serialization > WCF and Custom Role Provider Problem
 

WCF and Custom Role Provider Problem

Hello everyone,
I am trying toImplement some security into my WCF classes but Iam having some problems with using a custom role provider. I seem to be implementing it correctly vs. everything I have read on how to implement it but I keep getting an error. If someone could please point me in the right direction it would be great. Below is theerror, my web.config, and myWCF method. I know the role provider is working because I have the role access on the page that is calling the service, and the page loads fine.

Error:Request for principal permission failed.

<system.serviceModel>
<bindings>
<wsHttpBinding>
<bindingname="WSHttpBinding_ICalculator"closeTimeout="00:01:00"
openTimeout="00:01:00"receiveTimeout="00:10:00"sendTimeout="00:01:00"
bypassProxyOnLocal="false"transactionFlow="false"hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288"maxReceivedMessageSize="65536"
messageEncoding="Text"textEncoding="utf-8"useDefaultWebProxy="true"
allowCookies="true">
<readerQuotasmaxDepth="32"maxStringContentLength="8192"maxArrayLength="16384"
maxBytesPerRead="4096"maxNameTableCharCount="16384"/>
<reliableSessionordered="true"inactivityTimeout="00:10:00"
enabled="false"/>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behaviorname="serviceBehavior">
<serviceAuthorizationprincipalPermissionMode="UseAspNetRoles"roleProviderName="CustomRoleProvider">
</serviceAuthorization>
<serviceCredentials>
<userNameAuthenticationuserNamePasswordValidationMode="MembershipProvider"membershipProviderName="CustomMembership"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<client>
<endpointaddress="http://localhost:8000/ServiceModelSamples/Service/CalculatorService"
binding="wsHttpBinding"bindingConfiguration="WSHttpBinding_ICalculator"
contract="ICalculator"name="WSHttpBinding_ICalculator"behaviorConfiguration="serviceBehavior">
</endpoint>
</client>
</system.serviceModel>
<system.web>
<roleManagerenabled="true"defaultProvider="CustomRoleProvider">
<providers>
<clear/>
<addname="CustomRoleProvider"type="WCFSecurityTest.CustomRoleProvider,WCFSecurityTest"/>
</providers>
</roleManager>
<membershipdefaultProvider="CustomMembership">
<providers>
<clear/>
<addname="CustomMembership"type="WCFSecurityTest.CustomMembership,WCFSecurityTest"/>
</providers>
</membership>

[PrincipalPermission(SecurityAction.Demand,Role="Admin")]
publicdoubleAdd(doublen1,doublen2)
{
//PrincipalPermissionp=new
//PrincipalPermission(null,"Admin");
//p.Demand();
doubleresult=n1+n2;
Console.WriteLine("ReceivedAdd({0},{1})",n1,n2);
//Codeaddedtowriteoutputtotheconsolewindow.
Console.WriteLine("Return:{0}",result);
returnresult;
}

Thank you.
Flash Gordon
The WCF forum will be better able to help:

http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=118&SiteID=1

Thanks.
Nathan Anderson - MSFT
The WCF forum will be better able to help:

http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=118&SiteID=1

Thanks.
Nathan Anderson - MSFT

You can use google to search for other answers

Custom Search

More Threads

• Does aspnet_compiler work with Cassini?
• modify URL of the stub at run time
• How to add prefix to parent namespace
• How to Develop AutoStart WebService?
• Global class identifier is not valid - Global is a keyword
• Most performant method to (de)serialize to/from XmlElement?
• Adding multiple child elements to a Class Member of type XmlElement
• Web Serivice Throwing Timeout Error
• Access data from one user control to another using a class library
• Walkthrough: Creating and Using an ASP.NET Web Service in Visual Web Developer