asp.netmvcサイトでフォーム認証を使用したい。
(リモートサーバー上の)既存のSQLデータベースを使用できますか?このデータベースを認証に使用するようにサイトを構成するにはどうすればよいですか?認証に必要な/使用されるテーブルはどれですか?
asp.netmvcサイトでフォーム認証を使用したい。
(リモートサーバー上の)既存のSQLデータベースを使用できますか?このデータベースを認証に使用するようにサイトを構成するにはどうすればよいですか?認証に必要な/使用されるテーブルはどれですか?
あなたはできる。aspnet_regsql.exe
特に、Windows\Microsoft.NET\Framework\v2.xxx フォルダーのプログラム パラメーターを確認してくださいsqlexportonly
。
必要なテーブルを作成したら、次のように構成できます。web.config ファイルに接続文字列を作成し、この接続文字列を使用するように MemberShipProvider を設定します。
<connectionStrings>
<add name="MyLocalSQLServer" connectionString="Initial Catalog=aspnetdb;data source=servername;uid=whatever;pwd=whatever;"/>
</connectionStrings>
<authentication mode="Forms">
<forms name="SqlAuthCookie" timeout="10" loginUrl="Login.aspx"/>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
<membership defaultProvider="MySqlMembershipProvider">
<providers>
<clear/>
<add name="MySqlMembershipProvider" connectionStringName="MyLocalSQLServer" applicationName="MyAppName" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</membership>
Ps:ここには、コンセプト全体に関する非常に優れた記事がいくつかあります。
The easiest manner is to just use the windows interface for the aspnet_regsql.exe application.
You can find it in the c:\windows\microsoft.net\framework\v2.0.50727 folder.
Just type in aspnet_regsql.exe, it will then open a wizard, this way you don't need to remember any command line switches.