简体   繁体   English

如何在PHP网站中集成ASP.NET成员资格?

[英]How do I integrate ASP.NET Membership in PHP sites?

I am looking to use an open source CMS/blog site like WordPress or Drupal. 我正在寻找使用像WordPress或Drupal这样的开源CMS /博客网站。 I need it to work with the ASP.NET Membership I already have running my current website and community site. 我需要它与ASP.NET Membership一起使用,我已经在运行当前的网站和社区网站。

I am assuming I need to muck with (hand write) some cookies to pass back and forth. 我假设我需要混入(手写)一些cookie来回传递。 So how would/have you done it? 那么,您会如何做呢? I am looking for creative ideas on how to make this happen smoothly and securely. 我正在寻找有关如何使此过程平稳且安全地发生的创意。

Drupal has a layered and pluggable authentication system , you can use that to connect to any external system for authentication. Drupal具有分层的可插入身份验证系统 ,您可以使用它来连接到任何外部系统以进行身份​​验证。

As commentor points out below, "external system" may be a bit ambigous. 正如评论员在下面指出的那样,“外部系统”可能有点含糊。

It does not have to be some XMLRPC, REST, or bus system, it can be anything, from a textfile in a directory to a table filled with legacy accounts in a "local" MySQL database. 它不一定是XMLRPC,REST或总线系统,它可以是任何东西,从目录中的文本文件到“本地” MySQL数据库中填充有旧帐户的表。 Point is, this pluggable authentication layer allows for any none Drupal-users-database-table to hook in an allow/disallow authentications/registrations. 关键是,该可插入身份验证层允许任何没有Drupal-users-database-table的钩子连接到允许/不允许的身份验证/注册。

I query the database for the appropriate fields and I use this to create my cookies in C# code, does that help you? 我在数据库中查询适当的字段,并使用它以C#代码创建cookie,这对您有帮助吗?

        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
           1,                            // version
           strUser,                      // user name
           DateTime.Now,                 // create time
           DateTime.Now.AddYears(1),     // expire time
           false,                        // persistent
           "my own data" );              // user data
        string strEncryptedTicket = FormsAuthentication.Encrypt( ticket );
        HttpCookie cookie = new HttpCookie( FormsAuthentication.FormsCookieName, strEncryptedTicket );
        Context.Response.Cookies.Add( cookie );

As for the queries to be run, those are straightforward and documented if you have an aspnetdb instance already up with an asp.net app using them, but I could post more code if you need some stuff for accessing those as well. 至于要运行的查询,如果您已经拥有一个使用它们的asp.net应用程序的aspnetdb实例,这些查询将很简单并记录下来,但是如果您还需要一些东西来访问它们,我可以发布更多代码。 You were asking about the cookie, so this is how I set my cookies in C# 您在询问Cookie,所以这就是我在C#中设置Cookie的方式

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

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