【问题标题】:WCF self hosting require authenticationWCF 自托管需要身份验证
【发布时间】:2012-11-27 02:06:14
【问题描述】:

如果我能提供一个 hello world 示例,我将不胜感激,我如何让客户端必须提供特定的用户名和密码才能使用 wcf 服务。我自己托管我的服务,因此它不在 IIS 上。

我有服务器 A 和客户端 B。它们是同一网络上的不同计算机。

我正在使用 Visual Studio 在创建新 WCF 类库时创建的默认 Service1 类。所以我在服务器 A 上创建了该服务。

然后在客户端 B 上,我添加了对该地址的服务引用,该地址恰好是: http://10.10.1.135:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/mex (客户端 B 是一个控制台应用)

为了使用该服务,我必须这样做:

    static void Main(string[] args)
    {
        ServiceReference1.Service1Client svc = new ServiceReference1.Service1Client();

        svc.ClientCredentials.Windows.ClientCredential.UserName = "MyUserName";
        svc.ClientCredentials.Windows.ClientCredential.Password = "MyPassword";

        var a = svc.GetData(5); // consume the service            
    }

注意我必须使用域用户的用户名和密码。 如何使用自定义密码执行类似操作?我不想提供这些凭据,也不想在 Windows 上创建新用户。如果我可以针对数据库进行验证,那就太好了。

【问题讨论】:

    标签: c# wcf authentication


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-13
    • 1970-01-01
    • 1970-01-01
    • 2011-07-05
    相关资源
    最近更新 更多