summaryrefslogtreecommitdiffstats
path: root/projecttemplates/WebFormsRelyingParty/Setup.aspx.cs
diff options
context:
space:
mode:
Diffstat (limited to 'projecttemplates/WebFormsRelyingParty/Setup.aspx.cs')
-rw-r--r--projecttemplates/WebFormsRelyingParty/Setup.aspx.cs29
1 files changed, 2 insertions, 27 deletions
diff --git a/projecttemplates/WebFormsRelyingParty/Setup.aspx.cs b/projecttemplates/WebFormsRelyingParty/Setup.aspx.cs
index 4f73c5f..22125a4 100644
--- a/projecttemplates/WebFormsRelyingParty/Setup.aspx.cs
+++ b/projecttemplates/WebFormsRelyingParty/Setup.aspx.cs
@@ -9,8 +9,7 @@
using System.Web.UI.WebControls;
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.RelyingParty;
- using Microsoft.SqlServer.Management.Common;
- using Microsoft.SqlServer.Management.Smo;
+ using RelyingPartyLogic;
public partial class Setup : System.Web.UI.Page {
private bool databaseCreated;
@@ -27,7 +26,7 @@
if (e.IsDirectedIdentity) {
this.noOPIdentifierLabel.Visible = true;
} else if (!this.databaseCreated) {
- this.CreateDatabase(e.ClaimedIdentifier, this.openidLogin.Text);
+ Utilities.CreateDatabase(e.ClaimedIdentifier, this.openidLogin.Text);
this.MultiView1.ActiveViewIndex = 1;
// indicate we have already created the database so that if the
@@ -36,29 +35,5 @@
this.databaseCreated = true;
}
}
-
- private void CreateDatabase(Identifier claimedId, string friendlyId) {
- const string SqlFormat = @"
-CREATE DATABASE [{0}] ON (NAME='{0}', FILENAME='{0}')
-GO
-USE ""{0}""
-GO
-{1}
-EXEC [dbo].[AddUser] 'admin', 'admin', '{2}', '{3}'
-GO
-";
- string databasePath = HttpContext.Current.Server.MapPath("~/App_Data/Database.mdf");
- string schemaSql = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Admin/CreateDatabase.sql"));
- string sql = string.Format(CultureInfo.InvariantCulture, SqlFormat, databasePath, schemaSql, claimedId, "Admin");
-
- var serverConnection = new ServerConnection(".\\sqlexpress");
- try {
- serverConnection.ExecuteNonQuery(sql);
- var server = new Server(serverConnection);
- server.DetachDatabase(databasePath, true);
- } finally {
- serverConnection.Disconnect();
- }
- }
}
}