I hope you people can clarify some of them for me. I have a web application using the Sql membership provider and it is talking to the second web application through the WCF service. Both applications use the same SAT server of the data provider ... but I need every WCF service call to authenticate the user.
Now I have looked through many examples, but it seems to me that the samples that I saw either do not contain specific code, because this "should" be obvious to me, or I misunderstand how WCF processes the request (see the expected code below) .
I am grateful for any help ...
HERE THAT I ALREADY KNOW HOW TO DO
- I know how to set up Sql membership at both ends.
- I know how to configure wsHttpBinding
- I know how to configure a service certificate used in transport security.
HERE IF I A CONFERENCE
- How can I pass a membership password (... you cannot)
- Do I skip authentication cookies? If so, how?
- Create a "known" username and password that are not associated with the user (yourself)?
ON THE WEB CUSTOMER I EXPECT TO SEE THE CODE, SOMETHING AS IT
protected void btnLogin_Click(object sender, EventArgs e)
{
if (Membership.ValidateUser("MyUserName", "MyPassword"))
{
FormsAuthentication.SetAuthCookie("MyUserName", true);
FormsAuthentication.RedirectFromLoginPage("MyUserName", false);
}
}
protected ServiceReference1.Contractor getContractor(Int32 key)
{
MembershipUser user = Membership.GetUser("MyUserName");
ServiceReference1.FishDataClient wcfService = new ServiceReference1.FishDataClient();
wcfService.ChannelFactory.Credentials.UserName.UserName = user.UserName;
wcfService.ChannelFactory.Credentials.UserName.Password = "??????";
ServiceReference1.Contractor contractor = wcfService.GetContractor(key);
wcfService.Close();
wcfService = null;
return contractor;
}
IN THE WCF SERVICE I EXPECTED TO SEE THE CODE, SOMETHING AS IT
[PrincipalPermission(SecurityAction.Demand, Role = "User")]
public Contractor GetContractor(Int32 key)
{
ServiceSecurityContext context = ServiceSecurityContext.Current;
Contractor contractor = new Contractor();
if (Membership.ValidateUser("???????", "???????"))
contractor.Get(key);
return contractor;
}
source
share