in Windows Azure

Using Cardspace authentication with .Net Services

If you want to use CardSpace authentication in your .Net services, then all you need to do is don’t add any authentication type to your binding 😉

Confused? Well, .Net Services by default uses CardSpace Authentication. So, all you need to supply is just your solution name and automatically you will be prompted for CardSpace authentication!

Here is my Service code

static void Main(string[] args){    Console.WriteLine("Enter your solution name : ");    string solutionName = Console.ReadLine();                    string serviceUri = String.Format("sb://{0}/services/{1}/HelloWorldService/",                                 ServiceBusEnvironment.DefaultRelayHostName,                                 solutionName);    ServiceHost serviceHost = new ServiceHost(typeof(HelloWorldService), new Uri(serviceUri));    serviceHost.Open();    Console.WriteLine("Service started - Press ENTER to stop");    Console.Read();    serviceHost.Close();}

 

And my config

<system.serviceModel>     <services>          <service name="Chaks.Samples.MyService.HelloWorldService">      <endpoint name="HelloWorldRelayEndpoint"                contract="Chaks.Samples.MyService.IHelloWorldService"                binding="netTcpRelayBinding"/>    </service>  </services></system.serviceModel>

 

But, if you do need to explicitly tell the Service Bus to use CardSpace Authentication, then you need to add an endpoint behavior which uses CardSpace authentication type to your config

<system.serviceModel>     <services>          <service name="Chaks.Samples.MyService.HelloWorldService">      <endpoint name="HelloWorldRelayEndpoint"                contract="Chaks.Samples.MyService.IHelloWorldService"                behaviorConfiguration="CardspaceCredentialsBehavior"                binding="netTcpRelayBinding"/>    </service>  </services>  <behaviors>    <endpointBehaviors>      <behavior name="CardspaceCredentialsBehavior">        <transportClientEndpointBehavior credentialType="CardSpace"/>      </behavior>    </endpointBehaviors>  </behaviors></system.serviceModel>

 

Write a Comment

Comment

Time limit is exhausted. Please reload the CAPTCHA.