static string [] schemaElements = new string [] {
// Applications table
@"CREATE TABLE aspnet_Applications (
- ApplicationId char(36) PRIMARY KEY,
+ ApplicationId char(36) NOT NULL PRIMARY KEY,
ApplicationName varchar(256) NOT NULL UNIQUE,
LoweredApplicationName varchar(256) NOT NULL UNIQUE,
Description varchar(256)
)",
- @"CREATE INDEX aspnet_Applications_Index ON aspnet_Applications(LoweredApplicationName)",
+ @"CREATE INDEX aspnet_App_Idx ON aspnet_Applications(LoweredApplicationName)",
// Users table
@"CREATE TABLE aspnet_Users (
IsAnonymous int NOT NULL DEFAULT 0,
LastActivityDate timestamp NOT NULL,
- CONSTRAINT Users_ApplicationId_PK FOREIGN KEY (ApplicationId) REFERENCES aspnet_Applications(ApplicationId)
+ CONSTRAINT Users_AppId_PK FOREIGN KEY (ApplicationId) REFERENCES aspnet_Applications(ApplicationId)
)",
- @"CREATE UNIQUE INDEX aspnet_Users_Index ON aspnet_Users(ApplicationId, LoweredUserName)",
- @"CREATE INDEX aspnet_Users_Index2 ON aspnet_Users(ApplicationId, LastActivityDate)",
+ @"CREATE UNIQUE INDEX aspnet_Usr_Idx ON aspnet_Users(ApplicationId, LoweredUserName)",
+ @"CREATE INDEX aspnet_Usr_Idx2 ON aspnet_Users(ApplicationId, LastActivityDate)",
// Membership table
@"CREATE TABLE aspnet_Membership (
LastPasswordChangedDate timestamp NOT NULL,
LastLockoutDate timestamp NOT NULL,
FailedPasswordAttemptCount int NOT NULL,
- FailedPasswordAttemptWindowStart timestamp NOT NULL,
- FailedPasswordAnswerAttemptCount int NOT NULL,
- FailedPasswordAnswerAttemptWindowStart timestamp NOT NULL,
+ FailedPwdAttemptWindowStart timestamp NOT NULL,
+ FailedPwdAnswerAttemptCount int NOT NULL,
+ FailedPwdAnswerAttWindowStart timestamp NOT NULL,
Comment varchar(256),
- CONSTRAINT Member_ApplicationId_PK FOREIGN KEY (ApplicationId) REFERENCES aspnet_Applications(ApplicationId),
+ CONSTRAINT Member_AppId_PK FOREIGN KEY (ApplicationId) REFERENCES aspnet_Applications(ApplicationId),
CONSTRAINT UserId_PK FOREIGN KEY (UserId) REFERENCES aspnet_Users(UserId)
)",
- @"CREATE INDEX aspnet_Membership_index ON aspnet_Membership(ApplicationId, LoweredEmail)",
+ @"CREATE INDEX aspnet_Mbr_idx ON aspnet_Membership(ApplicationId, LoweredEmail)",
// Roles table
@"CREATE TABLE aspnet_Roles (
LoweredRoleName varchar(256) NOT NULL,
Description varchar(256),
- CONSTRAINT Roles_ApplicationId_PK FOREIGN KEY (ApplicationId) REFERENCES aspnet_Applications(ApplicationId)
+ CONSTRAINT Roles_AppId_PK FOREIGN KEY (ApplicationId) REFERENCES aspnet_Applications(ApplicationId)
)",
- @"CREATE UNIQUE INDEX aspnet_Roles_index ON aspnet_Roles(ApplicationId, LoweredRoleName)",
+ @"CREATE UNIQUE INDEX aspnet_Rls_idx ON aspnet_Roles(ApplicationId, LoweredRoleName)",
// UsersInRoles table
@"CREATE TABLE aspnet_UsersInRoles (
CONSTRAINT UserId_RoleId_PK FOREIGN KEY (RoleId) REFERENCES aspnet_Roles (RoleId)
)",
@"ALTER TABLE aspnet_UsersInRoles ADD PRIMARY KEY (UserId, RoleId)",
- @"CREATE INDEX aspnet_UsersInRoles_index ON aspnet_UsersInRoles(RoleId)",
+ @"CREATE INDEX aspnet_UsrRls_idx ON aspnet_UsersInRoles(RoleId)",
// Profile table
@"CREATE TABLE aspnet_Profile (
)",
// Pathes table
- @"CREATE TABLE aspnet_Paths (
- ApplicationId char(36) NOT NULL,
- PathId char(36) NOT NULL PRIMARY KEY,
- Path varchar(256) NOT NULL,
- LoweredPath varchar(256) NOT NULL,
-
- CONSTRAINT Paths_ApplicationId_FK FOREIGN KEY (ApplicationId) REFERENCES aspnet_Applications(ApplicationId)
- )",
- @"CREATE UNIQUE INDEX aspnet_Paths_index ON aspnet_Paths(ApplicationId, LoweredPath)",
+ //@"CREATE TABLE aspnet_Paths (
+ // ApplicationId char(36) NOT NULL,
+ // PathId char(36) NOT NULL PRIMARY KEY,
+ // Path varchar(256) NOT NULL,
+ // LoweredPath varchar(256) NOT NULL,
+ //
+ // CONSTRAINT Paths_AppId_FK FOREIGN KEY (ApplicationId) REFERENCES aspnet_Applications(ApplicationId)
+ //)",
+ //@"CREATE UNIQUE INDEX aspnet_Pth_idx ON aspnet_Paths(ApplicationId, LoweredPath)",
// Personalization tables
- @"CREATE TABLE aspnet_PersonalizationAllUsers (
- PathId char(36) NOT NULL PRIMARY KEY,
- PageSettings blob NOT NULL,
- LastUpdatedDate timestamp NOT NULL,
-
- CONSTRAINT PersnlUsers_PathId_PK FOREIGN KEY (PathId) REFERENCES aspnet_Paths (PathId)
- )",
- @"CREATE TABLE aspnet_PersonalizationPerUser (
- Id char(36) NOT NULL PRIMARY KEY,
- PathId char(36) NOT NULL,
- UserId char(36) NOT NULL,
- PageSettings blob NOT NULL,
- LastUpdatedDate timestamp NOT NULL,
-
- CONSTRAINT PersnlPerUser_PathId_FK FOREIGN KEY (PathId) REFERENCES aspnet_Paths (PathId),
- CONSTRAINT PersnlPerUser_UserId_FK FOREIGN KEY (UserId) REFERENCES aspnet_Users (UserId)
- )",
- @"CREATE UNIQUE INDEX aspnet_PersonalizationPerUser_index1 ON aspnet_PersonalizationPerUser(PathId,UserId)",
- @"CREATE UNIQUE INDEX aspnet_PersonalizationPerUser_ncindex2 ON aspnet_PersonalizationPerUser(UserId,PathId)"
+ //@"CREATE TABLE aspnet_PersonalizationAllUsers (
+ // PathId char(36) NOT NULL PRIMARY KEY,
+ // PageSettings blob NOT NULL,
+ // LastUpdatedDate timestamp NOT NULL,
+ //
+ // CONSTRAINT PrsUsr_PathId_PK FOREIGN KEY (PathId) REFERENCES aspnet_Paths (PathId)
+ //)",
+ //@"CREATE TABLE aspnet_PersonalizationPerUser (
+ // Id char(36) NOT NULL PRIMARY KEY,
+ // PathId char(36) NOT NULL,
+ // UserId char(36) NOT NULL,
+ // PageSettings blob NOT NULL,
+ // LastUpdatedDate timestamp NOT NULL,
+ //
+ // CONSTRAINT PrsPUser_PathId_FK FOREIGN KEY (PathId) REFERENCES aspnet_Paths (PathId),
+ // CONSTRAINT PrsPUser_UserId_FK FOREIGN KEY (UserId) REFERENCES aspnet_Users (UserId)
+ //)",
+ //@"CREATE UNIQUE INDEX PrsPUser_idx1 ON aspnet_PersonalizationPerUser(PathId,UserId)",
+ //@"CREATE UNIQUE INDEX PrsPUser_idx2 ON aspnet_PersonalizationPerUser(UserId,PathId)"
};
#endregion
connection.Open ();
- using (connection) {
- for (int i = 0; i < schemaElements.Length; i++) {
- try {
- OleDbCommand cmd = new OleDbCommand (schemaElements [i], connection);
- cmd.ExecuteNonQuery ();
- }
- catch (Exception) {
- }
+ using (connection) {\r
+ for (int i = 0; i < schemaElements.Length; i++) {\r
+ OleDbCommand cmd = new OleDbCommand (schemaElements [i], connection);\r
+ cmd.ExecuteNonQuery ();\r
}
}
}
\r
string queryInsertMbr = "INSERT INTO aspnet_Membership (ApplicationId, UserId, Password, PasswordFormat, PasswordSalt, Email, " +\r
"LoweredEmail, PasswordQuestion, PasswordAnswer, IsApproved, IsLockedOut, CreateDate, LastLoginDate, " +\r
- "LastPasswordChangedDate, LastLockoutDate, FailedPasswordAttemptCount, FailedPasswordAttemptWindowStart, " +\r
- "FailedPasswordAnswerAttemptCount, FailedPasswordAnswerAttemptWindowStart) " +\r
+ "LastPasswordChangedDate, LastLockoutDate, FailedPasswordAttemptCount, FailedPwdAttemptWindowStart, " +\r
+ "FailedPwdAnswerAttemptCount, FailedPwdAnswerAttWindowStart) " +\r
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";\r
OleDbCommand cmdInsertMbr = new OleDbCommand (queryInsertMbr, (OleDbConnection) connection);\r
cmdInsertMbr.Transaction = trans;\r
AddParameter (cmdInsertMbr, "LastPasswordChangedDate", createDate);\r
AddParameter (cmdInsertMbr, "LastLockoutDate", DefaultDateTime);\r
AddParameter (cmdInsertMbr, "FailedPasswordAttemptCount", 0);\r
- AddParameter (cmdInsertMbr, "FailedPasswordAttemptWindowStart", DefaultDateTime);\r
- AddParameter (cmdInsertMbr, "FailedPasswordAnswerAttemptCount", 0);\r
- AddParameter (cmdInsertMbr, "FailedPasswordAnswerAttemptWindowStart", DefaultDateTime);\r
+ AddParameter (cmdInsertMbr, "FailedPwdAttemptWindowStart", DefaultDateTime);\r
+ AddParameter (cmdInsertMbr, "FailedPwdAnswerAttemptCount", 0);\r
+ AddParameter (cmdInsertMbr, "FailedPwdAnswerAttWindowStart", DefaultDateTime);\r
cmdInsertMbr.ExecuteNonQuery ();\r
\r
trans.Commit ();\r
public static int Membership_GetPassword (DbConnection connection, string applicationName, string username, string passwordAnswer, int maxInvalidPasswordAttempts, int passwordAttemptWindow, DateTime currentTimeUtc, out string password)\r
{\r
string querySelect = "SELECT usr.UserId, mbr.Password, mbr.PasswordAnswer, mbr.IsLockedOut, " +\r
- "mbr.LastLockoutDate, mbr.FailedPasswordAnswerAttemptCount, mbr.FailedPasswordAnswerAttemptWindowStart " +\r
+ "mbr.LastLockoutDate, mbr.FailedPwdAnswerAttemptCount, mbr.FailedPwdAnswerAttWindowStart " +\r
"FROM aspnet_Applications app, aspnet_Users usr, aspnet_Membership mbr " +\r
"WHERE app.LoweredApplicationName = ? AND usr.ApplicationId = app.ApplicationId " +\r
"AND usr.UserId = mbr.UserId AND usr.LoweredUserName = ?";\r
}\r
\r
string queryUpdate = "UPDATE aspnet_Membership SET IsLockedOut = ?, LastLockoutDate = ?, " +\r
- "FailedPasswordAnswerAttemptCount = ?, FailedPasswordAnswerAttemptWindowStart = ? " +\r
+ "FailedPwdAnswerAttemptCount = ?, FailedPwdAnswerAttWindowStart = ? " +\r
"WHERE UserId = ?";\r
OleDbCommand cmdUpdate = new OleDbCommand (queryUpdate, (OleDbConnection) connection);\r
AddParameter (cmdUpdate, "IsLockedOut", dbLockedOut);\r
AddParameter (cmdUpdate, "LastLockoutDate", dbLastLockoutDate);\r
- AddParameter (cmdUpdate, "FailedPasswordAnswerAttemptCount", dbFailedPasswordAnswerAttemptCount);\r
- AddParameter (cmdUpdate, "FailedPasswordAnswerAttemptWindowStart", dbFailedPasswordAnswerAttemptWindowStart);\r
+ AddParameter (cmdUpdate, "FailedPwdAnswerAttemptCount", dbFailedPasswordAnswerAttemptCount);\r
+ AddParameter (cmdUpdate, "FailedPwdAnswerAttWindowStart", dbFailedPasswordAnswerAttemptWindowStart);\r
AddParameter (cmdUpdate, "UserId", dbUserId);\r
cmdUpdate.ExecuteNonQuery ();\r
\r
public static int Membership_GetPasswordWithFormat (DbConnection connection, string applicationName, string username, bool updateLastActivity, DateTime currentTimeUtc, out DbDataReader reader)\r
{\r
string querySelect = "SELECT usr.UserId, mbr.IsLockedOut, mbr.IsApproved, mbr.Password, mbr.PasswordFormat, mbr.PasswordSalt, " +\r
- "mbr.FailedPasswordAttemptCount, mbr.FailedPasswordAnswerAttemptCount, mbr.LastLoginDate, usr.LastActivityDate " +\r
+ "mbr.FailedPasswordAttemptCount, mbr.FailedPwdAnswerAttemptCount, mbr.LastLoginDate, usr.LastActivityDate " +\r
"FROM aspnet_Applications app, aspnet_Users usr, aspnet_Membership mbr " +\r
"WHERE app.LoweredApplicationName = ? AND usr.ApplicationId = app.ApplicationId " +\r
"AND usr.UserId = mbr.UserId AND usr.LoweredUserName = ?";\r
public static int Membership_ResetPassword (DbConnection connection, string applicationName, string username, string newPassword, string passwordAnswer, int passwordFormat, string passwordSalt, int maxInvalidPasswordAttempts, int passwordAttemptWindow, DateTime currentTimeUtc)\r
{\r
string querySelect = "SELECT usr.UserId, mbr.Password, mbr.PasswordAnswer, mbr.IsLockedOut, " +\r
- "mbr.LastLockoutDate, mbr.FailedPasswordAnswerAttemptCount, mbr.FailedPasswordAnswerAttemptWindowStart " +\r
+ "mbr.LastLockoutDate, mbr.FailedPwdAnswerAttemptCount, mbr.FailedPwdAnswerAttWindowStart " +\r
"FROM aspnet_Applications app, aspnet_Users usr, aspnet_Membership mbr " +\r
"WHERE app.LoweredApplicationName = ? AND usr.ApplicationId = app.ApplicationId " +\r
"AND usr.UserId = mbr.UserId AND usr.LoweredUserName = ?";\r
return 1; // user not found\r
\r
string queryUnlock = "UPDATE aspnet_Membership SET IsLockedOut = 0, " +\r
- "FailedPasswordAttemptCount = 0, FailedPasswordAttemptWindowStart = ?, " +\r
- "FailedPasswordAnswerAttemptCount = 0, FailedPasswordAnswerAttemptWindowStart = ?, " +\r
+ "FailedPasswordAttemptCount = 0, FailedPwdAttemptWindowStart = ?, " +\r
+ "FailedPwdAnswerAttemptCount = 0, FailedPwdAnswerAttWindowStart = ?, " +\r
"LastLockoutDate = ? WHERE UserId = ?";\r
OleDbCommand cmdUnlock = new OleDbCommand (queryUnlock, (OleDbConnection) connection);\r
- AddParameter (cmdUnlock, "FailedPasswordAttemptWindowStart", DefaultDateTime);\r
- AddParameter (cmdUnlock, "FailedPasswordAnswerAttemptWindowStart", DefaultDateTime);\r
+ AddParameter (cmdUnlock, "FailedPwdAttemptWindowStart", DefaultDateTime);\r
+ AddParameter (cmdUnlock, "FailedPwdAnswerAttWindowStart", DefaultDateTime);\r
AddParameter (cmdUnlock, "LastLockoutDate", DefaultDateTime);\r
AddParameter (cmdUnlock, "UserId", userId);\r
\r
public static int Membership_UpdateUserInfo (DbConnection connection, string applicationName, string username, bool isPasswordCorrect, bool updateLastLoginActivityDate, int maxInvalidPasswordAttempts, int passwordAttemptWindow, DateTime currentTimeUtc, DateTime lastLoginDate, DateTime lastActivityDate)\r
{\r
string querySelect = "SELECT usr.UserId, mbr.IsApproved, mbr.IsLockedOut, mbr.LastLockoutDate, " +\r
- "mbr.FailedPasswordAttemptCount, mbr.FailedPasswordAttemptWindowStart " +\r
+ "mbr.FailedPasswordAttemptCount, mbr.FailedPwdAttemptWindowStart " +\r
"FROM aspnet_Applications app, aspnet_Users usr, aspnet_Membership mbr " +\r
"WHERE app.LoweredApplicationName = ? AND usr.ApplicationId = app.ApplicationId " +\r
"AND usr.UserId = mbr.UserId AND usr.LoweredUserName = ?";\r
}\r
\r
string queryUpdate = "UPDATE aspnet_Membership SET IsLockedOut = ?, LastLockoutDate = ?, " +\r
- "FailedPasswordAttemptCount = ?, FailedPasswordAttemptWindowStart = ? " +\r
+ "FailedPasswordAttemptCount = ?, FailedPwdAttemptWindowStart = ? " +\r
"WHERE UserId = ?";\r
OleDbCommand cmdUpdate = new OleDbCommand (queryUpdate, (OleDbConnection) connection);\r
AddParameter (cmdUpdate, "IsLockedOut", dbLockedOut);\r
AddParameter (cmdUpdate, "LastLockoutDate", dbLastLockoutDate);\r
AddParameter (cmdUpdate, "FailedPasswordAttemptCount", dbFailedPasswordAttemptCount);\r
- AddParameter (cmdUpdate, "FailedPasswordAttemptWindowStart", dbFailedPasswordAttemptWindowStart);\r
+ AddParameter (cmdUpdate, "FailedPwdAttemptWindowStart", dbFailedPasswordAttemptWindowStart);\r
AddParameter (cmdUpdate, "UserId", dbUserId);\r
cmdUpdate.ExecuteNonQuery ();\r
return 0;\r