使用C#SOA方法验证 [英] Authentication with an SOA approach using C#

查看:286
本文介绍了使用C#SOA方法验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了重建一个网站,我尝试使用SOA方法。目前的网站是在.NET 2.0,并使用现成的SqlMembershipProvider的。

I am doing a rebuild of a website and I'm trying to use an SOA approach. The current website is in .NET 2.0 and uses the out of the box SqlMembershipProvider.

我们正在试图消除对数据库的直接连接,并通过WCF服务一切推层。我们使用这种情况的方法是让一切分离 - 有对模型和接口库,服务库,然后为服务代理库

We're trying to eliminate direct connections to the database and push everything through a WCF service layer. The approach we're using for this is to have everything separated - There's a library for models and interfaces, a library for the services, and then a library for the service proxies.

最大的障碍,到目前为止是搞清楚如何管理用户认证和他们的会话。什么是使用这种方法来做到这一点的最好办法。

The biggest hurdle so far is figuring out how to manage user authentication and their session. What's the best way to do this with this approach.

我们应该报废.NET会员制模式,并与类似的OpenID去,只允许用户将他们的数据重新连接到新帐户?

Should we scrap the .NET membership model and go with something like OpenId, and just allow users to reconnect their data to the new account?

我已经做了一些搜索和无法找到如何管理这个有很多,虽然我知道它已经做过的事情。

I've done some searching and can't find a lot on how to manage this, though I know it's been done before.

推荐答案

下面是我落得这样做,如果有人有兴趣。我开始使用WCF认证服务,但后来意识到它没有给我我想要的一切。我可以登录和注销,但还是要创建自己的登记和取得的MembershipUser方法。

Here's what I ended up doing, in case anyone is interested. I started off using the WCF Authentication Services, but then realized it didn't give me everything I wanted. I could log on and off, but will still have to create my own methods for registration and getting the MembershipUser.

所以我在ServiceContracts库中去,并创建一个接口I所谓IMembership。起初,我创建它作为一类和继承的MembershipProvider这样我就可以得到所有为我所生成的方法存根。一旦生成了我修改了存根并使它成为一个接口。

So I went in my ServiceContracts library and create an interface I called IMembership. At first, I created it as a class and inherited from MembershipProvider so that I could get all the method stubs generated for me. Once they were generated I modified the stubs and made it into an interface.

然后,我走进我的服务资料库,创造了这是简单的接口的实现,因为我只是用Membership.Provider实施....

Then I went into my Services Library and created the implementation for the interface which was simple, because for the implementation I just used Membership.Provider....

然后在我的服务提供商客户端库,我做了通常的实现IMembership接口,还自ClientBase<继承; >。紧挨着它,我创建了一个WCFMembershipProvider,它实现的MembershipProvider,并呼吁从我刚刚创建的MembershipClient的方法。

Then in my Service Provider Clients library, I did the usual implementing of the IMembership interface, also inheriting from ClientBase<>. Right next to it I created a WCFMembershipProvider, which implemented MembershipProvider, and called the methods from the MembershipClient I just created.

在我的Web应用程序托管WCF服务我成立在web.config中我的SQL成员资格提供程序,然后创建了SVC文件和端点的服务。

In my WebApp that host the WCF Services I set up my SQL Membership provider in the web.config, and then created my svc file and endpoints for the service.

在使用Web应用程序,我刚添加的服务客户端参考。对SVC,然后设置为我WCFMembershipProvider成员资格提供

In the consuming web app, I just added the service client reference to the svc, and then set up the Membership Provider for my WCFMembershipProvider.

和中提琴 - 我在商业

And viola - I'm in business.

很多重复的代码,但它的作品不错。

A lot of repetitive code, but it works nice.

这篇关于使用C#SOA方法验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆