Search
Submit & Win
Submit and win
Cash Prizes !
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Articles Author
Mon, 22-Dec-2014 Authors
All Time Authors
Sourav.Kayal
39750
SheoNarayan
38550
Niladri.biswas
33350

Latest members | More ...


(Statistics delayed by 5 minutes)
Ads
 Article

Membership provider with WCF

Anup1252000
Posted by under WCF category on for Beginner level | Views : 26387 red flag
If you found plagiarised (copied) or inappropriate content,
please let us know the original source along with your correct email id (to communicate) for further action.
Rating: 5 out of 5
2 vote(s)
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.

Page copy protected against web site content infringement by Copyscape
About the Author

Anup1252000

Full Name: anup hosur
Member Level:
Member Status: Member
Member Since: 8/1/2009 2:37:23 AM
Country: India

Login to vote for this post.
Share this to:

Bookmark It

Comments or Responses

Posted by: Lopez.obrador on: 1/4/2011 | 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 on: 1/5/2011 | 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 on: 12/13/2011 | 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 on: 12/13/2011 | 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.

Login to post response

Comment using Facebook(Author doesn't get notification)