Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 1011 |  Welcome, Guest!   Register  Login
Home > Articles > WCF > Membership provider with WCF

Membership provider with WCF

2 vote(s)
Rating: 5 out of 5
Article posted by Anup1252000 on 2/11/2010 | Views: 21590 | Category: WCF | Level: Beginner red flag


In this article, we are going to see how to use membership provider with WCF.

Introduction

        In this article, we are going to see how to use membership provider with WCF. Let us go through this application step by step.

Step 1:

       Create a new Website->Select a WCFService->name it as service

 

Step 2:

       Here i am keeping interface as it is. In this application, we are suppose to discuss so many things.


Step 3:

   Now we are suppose to create a forms authentication database. I suggest you to read this article, it contains information on how to create a forms authentication database

http://msdn.microsoft.com/en-us/library/x28wfk74.aspx

Step 4:

   Now at this point of time lets create a certificate. Go through this article

http://www.inventec.ch/chdh/notes/14.htm

 

Step 5:

   Now lets write our web.config.

First connect to database and give the connectionstring

 

Step 6:

     Now create membershipProvider in web.config

       


Set the authentication mode to Forms

<authentication mode="Forms"/>

 

Step 7:

    Under System.ServiceModel write these lines in web.config

  Here I will suggest you to check those imp things

   1)Message credential type as UserName

   2)negostiate Service credential to false

   3)Service cerificate

   4)UserNameAuthentication->set UserNamepasswordvalidatormode=MembershipProvider and MembershipProviderName as membership. In my case membership provider name is membership.

To check the thumb print value of the certificate go through this

http://msdn.microsoft.com/en-us/library/ms734695.aspx.

Step 8:

       Now create a new console app project->name it as client


Step 9:

      Give a service reference to Console app(client)-> name the reference as ServiceReference1

 

Step 10:

       


Here i am creating the proxy and setting the username and password in my case username is anup and password is AnUpHoSuR@.

 

Step 11:

      Now create a service certificate in a client as you did in Service.


Step 12:

    Its time to run your app

 

I hope you people like this article.

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About anup hosur

Experience:2 year(s)
Home page:
Member since:Saturday, August 01, 2009
Level:Starter
Status: [Member]
Biography:
 Responses
Posted by: Lopez.obrador | Posted on: 04 Jan 2011 05:03:48 PM | Points: 25

Hi anup.
GREAT article. I'm kind of a noob in .NET so some of the concepts are totally unknown to me plus some of the config code is not fully visible.
Also, I'm not fully sure as to where the certs should be placed (In the client and server) And where should Step 11 be written, In the Service web.config??
Would it be possible to get the project so I can take a look at it PLEASE !!

Many thanks.
Regards.



Posted by: Anup1252000 | Posted on: 05 Jan 2011 12:11:58 AM | Points: 25

Hi Lopez,

Thanks for reading the article.Step11 is nothing but a client Config.
I will add sample solution to this article in a day or 2. After adding i will let you know.



Thankx,
Anup

Posted by: Sonisp | Posted on: 13 Dec 2011 06:37:27 AM | Points: 25

Dear Anup,

Am trying this example, and was able to create the certificate as instructed above. But I have the following queries,

1. The link for getting Thumbprint of the certificate I just created talks about finding based on "Intended Purpose=Client Authentication", but based on your command the certificate which i created has this value "Intended Purpose=Server Authentication". Any What am i doing wrong? Or can I use the same regardless of the value of Intended Purpose.

2. How would this approach help when i have the client application trying to consume the same Service from another machine? Do I need to install the certificated per client on each local machine?

Rgds,

Posted by: Anup1252000 | Posted on: 13 Dec 2011 07:41:56 AM | Points: 25

1) Use the same certificate if you doing it for testing purpose. If you want to use in production then create different certificate for client.
2) Yes you have to install certificate on each client m/c.

Let me know if you have any issue on the same.

>> Write Response - Respond to this post and get points
Related Posts

This is Part 2 and concluding part of my Article New Features of WCF 4.0.

To Create and Host WCF Application in IIS Server.

A Simple application to implement Wcf using NetTcpBinding

This post teaches you how can you unleash the power of WCF and JSON. Complete walkthrough with sample code as download

In this article, we are going to see how to host Windows service in WCF and automatically start and stop the Service by using Button click events.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/19/2013 4:58:05 PM