protected virtual IQueryContext OnAuthenticate(string defaultSchema, string username, string password) { var user = Database.Authenticate(username, password, RemoteEndPoint); if (user == null) return null; var connection = Database.CreateUserSession(user); // Put the connection in exclusive mode connection.ExclusiveLock(); var context = new SessionQueryContext(connection); try { // By default, connections are auto-commit connection.AutoCommit(true); // Set the default schema for this connection if it exists if (context.SchemaExists(defaultSchema)) { context.CurrentSchema(defaultSchema); } else { // TODO: Log the warning.. // If we can't change to the schema then change to the APP schema connection.CurrentSchema(Database.DatabaseContext.DefaultSchema()); } } finally { try { connection.Commit(); } catch (TransactionException e) { // TODO: Log the warning } } return context; }