【发布时间】:2015-09-03 11:23:30
【问题描述】:
我正在为 Intranet 应用程序编写 WCF 服务器。我是 WCF 的新手,对身份验证有一些疑问。对于此服务器,绑定将为 netTcp,建议使用带有 Windows 身份验证的 netTcpBinding。但是对于我的要求,我需要一个自定义登录,用户将使用他自己的凭据而不是 Windows 凭据进行验证。
我计划以这种方式实施服务合同并验证登录凭据
*[ServiceContract(SessionMode = SessionMode.Required)]
public interface Iservice
{
[OperationContract]
String Login(String username, String password);
}
[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession) ]
public class serviceclass : Iservice
{
String Login(String username, String password);
{
//Validate uname and password with DB.
if (validate)
return OperationContext.Current.SessionId;
else return String.Empty;
}
}*
Is this a good approach or is there a better approach to acheive this.
请指导。
【问题讨论】:
标签: wcf authentication nettcpbinding