简体   繁体   English

指定用于WCF身份验证的应用程序名称

[英]Specifying Application Name for WCF authentication

I am thinking to host same service for multiple clients on there respective virtual directories in IIS. 我正在考虑在IIS中的相应虚拟目录上为多个客户端托管相同的服务。 so basically there will be one service on disk, that will be referenced by multiple IIS hosted virtual directories, this will give me some thing like this: 因此,基本上在磁盘上将只有一项服务,该服务将由多个IIS托管的虚拟目录引用,这将给我一些类似的信息:

http://myservice/client1 http:// myservice / client1

http://myservice/client2 http:// myservice / client2

...etc ...等等

I will make the service contract generalized. 我将使服务合同通用化。 this will give me one contract for all clients. 这将给我所有客户一份合同。

The underlying database would be different for all clients (schema is same), i will connect to the clients respective database by figuring out from the url used to access the service, if it was http://myservice/client1 i'll connect to dbClient1, if it was http://myservice/client2 i'll connect to dbClient2 ... etc 对于所有客户端,基础数据库都将有所不同(模式相同),我将通过从用于访问服务的url中找出(如果它是http:// myservice / client1 )连接到客户端相应的数据库,我将连接到dbClient1,如果它是http:// myservice / client2,我将连接到dbClient2 ...等等

THE CHALLENGE: 挑战:

the above will resolve most of the problems, except the authentication process (I am using ASP Membership, forms authentication). 以上将解决大多数问题,但身份验证过程除外(我正在使用ASP成员身份,表单身份验证)。 my service is on https basicHttp binding, so i don't have sessions. 我的服务基于https basicHttp绑定,所以我没有会话。

How do I specify what application name to use for user authentication. 如何指定用于用户身份验证的应用程序名称。 (all clients have separate application names, stored in ONE ASP Membership Database) If i change at Global.asax under Application_AuthenticateRequest, it does work, as i can get the URL at that time, and specify the application name to be used while authentication, but this changes application name for other callers as well ... which is not good at all .... (所有客户端都有单独的应用程序名称,存储在一个ASP成员数据库中)如果我在Global.asax的Application_AuthenticateRequest下进行更改,它确实可以正常工作,因为我当时可以获取URL,并指定身份验证时要使用的应用程序名称,但这也会更改其他呼叫者的应用程序名称...一点都不好....

So all i need is some way to tell my service that look for this username/password under this application in that database. 因此,我所需要的只是一种告诉服务的方式,即在该数据库中的该应用程序下查找该用户名/密码。 (database would be same for all clients in authentication case). (在身份验证的情况下,所有客户端的数据库都是相同的)。 But i want the change of application name for that particular session/instance ... (not sure if these two are available in https basicHttp binding) 但是我想更改该特定会话/实例的应用程序名称...(不确定这两个在https basicHttp绑定中是否可用)

if i can resolve this matter i'll be all well .... 如果我能解决这个问题,我会很好的....

please help ... thanks 请帮助...谢谢

It appears that your using ASP.NET infrastructure for authentication. 看来您使用ASP.NET基础结构进行身份验证。 What kind of MemberShipProvider are you using? 您正在使用哪种MemberShipProvider? You need to write a custom provider that figures out the application name using the current request url. 您需要编写一个自定义提供程序,以使用当前请求url找出应用程序名称。 For example, here's the one that is based on SqlMembershipProvider : 例如,这是基于SqlMembershipProvider

public class MyMembershipProvider : SqlMembershipProvider
{

    public override string ApplicationName 
    { 
      get
      {
          var url = HttpContext.Current.Request.Url;
          // find out the application name from  url
      }
      set
      {
         base.ApplicationName = value;
      }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM