限制WCF服务于特定用户帐户的最佳方式 [英] Best way to limit WCF Service to specific User Accounts

查看:126
本文介绍了限制WCF服务于特定用户帐户的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会主办使用窗口服务/服务主机一个基本的HTTP WCF服务。 我想服务限制在2特定的窗口Active Directory用户和这些帐户将珠三角和DEV环境之间的不同,所以他们会在配置文件中设置。

I will be hosting a basic HTTP WCF service using Window Service / Service Host. I would like to limit the service to 2 specific window active directory users and these accounts will vary between PRD and DEV environments so they will be set in a config file.

我想知道什么是做到这一点的最好办法,我知道,通常,如果我主持使用IIS则服务我可以在Web.config限制它: <一href="http://www.rickgaribay.net/archive/2007/04/04/recipe-wcf-basichttpbinding-with-windows-authentication.aspx" rel="nofollow">http://www.rickgaribay.net/archive/2007/04/04/recipe-wcf-basichttpbinding-with-windows-authentication.aspx 然而,由于我使用ServiceHost的话,我不认为这是一种选择托管。

I was wondering what is the best way to do this, I know normally if I was hosting the service using IIS then I could limit it in the Web.config: http://www.rickgaribay.net/archive/2007/04/04/recipe-wcf-basichttpbinding-with-windows-authentication.aspx However since i'm hosting using ServiceHost then I don't believe this is an option.

从我读似乎可以用声明的PrincipalPermission属性在服务类级别做到这一点: http://msdn.microsoft.com/ EN-US /库/ vstudio / ms731200(V = VS.100)的.aspx 但是我不是太清楚这是否会通过窗口服务或提出的HTTP请求的帐户的窗口帐户。我需要的是通过HTTP请求的帐户。 此外,与declartive属性,它是可以使用的配置文件属性,而不是硬codeD吗?

From what I read it seems possible to do this using PrincipalPermission Declarative attribute at the service class level: http://msdn.microsoft.com/en-us/library/vstudio/ms731200(v=vs.100).aspx However I'm not too clear whether this will pass the window account of window service or the account which made the HTTP request. What I need is to pass the HTTP request account. Also, with declartive attributes, is it possible to use a config file attribute rather than a hard coded one?

任何建议,如果您需要任何更多的信息,然后让我知道。

Any suggestions, if you need any more info then let me know.

推荐答案

我使用的是行为发现下面的文章适合我需要的东西,基本上它涉及到授权: 的http://allen-conway-dotnet.blogspot.co.uk/2010/01/how-to-create-aspnet-windows.html

I found the following article suitable for what I needed, basically it involved authorisation using a behavior: http://allen-conway-dotnet.blogspot.co.uk/2010/01/how-to-create-aspnet-windows.html

这篇关于限制WCF服务于特定用户帐户的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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