views:

447

answers:

3

I have a solution with 2 projects. In the first project a I have a website with a Logon Control. In the second project I have a WCF project with an AuthenticatonService configured. What is the easiest way to integrate both? In other word, How do I call the Authentication Service from the login control?

EDIT:

OK, what I mean is that by default, you can set the MembershipProvider property in a login control for authentication. This property refers to a locally defined provider in machine.config or web.config.

what I want is to stop using that provider defined locally and call the remote WCF authentication service instead. Sorry for not making myself clear.

+1  A: 

I believe this is what you're looking for: Exposing WCF Services to Client Scripts

Gavin Miller
Thanks, I went through that tutotorial already. Although it helped me configuring my authentication service, it does not show how to call the service from a remote website(i.e a login control)
Igor Zelaya
If it's a web service you need only publicly expose it for a remote website to use it. Or am I misunderstanding the question?
Gavin Miller
A: 

I think you need to write a membership provider that calls your Authentication service during the ValidateUser method.

The AuthenticationService allows you to use the ASP.NET Membership system to authenticate users in other applications - rather than providing a mechanism for authenticating users on the website itself.

Zhaph - Ben Duguid
Yes, I undesrtand. What I was trying to do is make the Login control use the WCF AuthenticationService.
Igor Zelaya
+1  A: 

OK,

Finally I got it working. This is what I did:

  • Add a Service Reference to the WCF url:

    http://localhost:8080/servicios/MiServicio.svc

  • Resetted the Membership Provider property of the Login control. This in facts look for the default membershipprovider installed with VS 2008 (SQLEXPRESS).

  • implement the Authenticate event. This has to be done in order to override the default behavior of authenticating with the default membership provider and do a custom authentication. In this event, create an instance of the proxy authenticationservice class and call Login method.

proteted void login_Authenticate(object sender, AuthenticateEventArgse){ AuthenticationServiceClient client = new AuthenticationServiceClient(); e.Authenticated = client.Login(login.UserName, login.Password, "", true); }

Igor Zelaya