How do I call an AuthenticationService from a login control?

Question!

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.



Answers

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); }



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.



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



This video can help you solving your question :)
By: admin