Windows Server configuration
Download
Report
Transcript Windows Server configuration
CONFIGURING
WINDOWS SERVER
MIS 424
Professor Sandvig
Overview
• In this exercise you will:
1.
Log onto Windows Server
2.
Create a new application pool
3.
Create a new web application
4.
Open Sql Server Management Studio
5.
Create a new Sql Server database
6.
Create a new Sql Server user
7.
Assign the user to the database
8.
Read your database from web page
Steps
• You will be provided with an instance of Windows Server
2008 hosted by on Amazon EC2 cloud
• The next several slides display how an instance is
launched from Amazon’s console. This has been done for
you.
Amazon Web Service Console
Select instance type
Instance
• Each instance is assigned a public IP address
• The following slide shows the instance management page
Instance Management
Instance Management
• Next step is to get the instance password
Instance management
Password
• Amazon generates a private key for each account.
• The private key is used to decrypt the password (next
slide)
Password
Password
• Ta-da!
Login
• Login to your instance using Remote Desktop
• Your IP address and password are on the next page
Login Passwords
Person
Public IP
username
Rachel
52.40.157.15
52.24.1.234
52.40.104.133
52.35.246.139
52.38.79.192
52.40.152.46
52.40.17.87
52.37.104.77
52.39.108.46
52.40.140.213
52.40.157.15
52.11.51.76
Administrator
Ryan
Jessica
Britt
Billy
Melanie
Michael
Meg
Sophia
Shawn
Natalie
Eric
Administrator
Administrator
Administrator
Administrator
Administrator
Administrator
Administrator
Administrator
Administrator
Administrator
Administrator
Password (cut & paste)
YhP8b977mq8vjkX@=m2K
5@MVnsqL2*f
uRw.mckXCX
uqgnHrJW?R
vnj?B)iVr*
8*Z%mW.e=y7
WuyQPc4P8vU
(Fc!A5CX8C
htFL29sWX)
YhP8b977m=8iMQhBt-Lv
View IIS Default
• By default Windows
hides file extensions
• Developers need to
see file extensions.
• In Windows Explorer
select Organize,
folder options.
• Change folder
options to show file
extensions
Permissions
• The default file location for
web pages is
C:inetpub/wwwroot.
• Navigate to wwwroot and
check folder permissions.
• Which permissions are
assigned to anonymous
web users?
View default web page
• Open browser on your local machine and view IIS default
web page
• Address is IP address of your instance
Modify default web page
• Use Notepad to edit the default web page
Create ASP.NET Application
• You will now use IIS to create a new ASP.NET application.
Create a ASP.NET Application
• Create a new folder named mis424Application
Create ASP.NET Application
• Search for IIS using
Windows search
• Open IIS 7.0 Manager
Create a new application pool
• Your application is important so provide it with its own
application pool
New Application pool
• Give the application pool the same name as the
application folder
• Change framework to 4.0
Create new Application
• Right click on your new folder
and convert it to an
application
• Select your new application
pool
Test your application
• Use Notepad to create a file default.aspx with the
following code:
<%@ Page Trace="true" Language="C#" %>
<script runat="server">
void page_load()
{
lblMessage.Text = ".NET Version: " + System.Environment.Version.ToString() +
"<br> Application Pool: " + Request.ServerVariables["APP_POOL_ID"] ;
}
</script>
<html>
<head>
<title>ASP.NET Test</title>
</head>
<body>
<asp:label id="lblMessage" runat="server" />
</body>
</html>
View new File
Database
• You have now configured an ASP.NET application
• The next step is to create a new SQL server database
and link to it from your web application.
Create a new database
• Open Sql Server
Management Studio on
the remote server
Connect to Sql Server
• Management
Studio will
automatically
select your
database server
• Click “Connect”
Create new database
• Name your new database “customers”
Create a new table (as shown)
Create new table
•
•
•
•
•
You will be connecting an .aspx page to your database
so make sure that all the names match the sample
Sql Server is case sensitive
custID is an identity field
custID is the primary key
Save the table with name tblCustomers
Add some data
Permissions
• Permissions are needed to access the database
• You will create a new user named webguest
• For security reasons webguest has only limited
permissions
• In the following steps you will:
Configure Sql Server to allow Sql server
authentication
2. create a new Sql Server user
1.
3.
Assign user permissions to your database
Allow Sql Server Authentication
• Using Sql Server
Management Studio
right-click on the
database server (top
folder) and and select
Properties
• Click on Security
• Change authentication
mode
Restart Database
• In Management Studio right-
click on server and select
restart
Add new Sql Server user
Add Sql user
• Username:
webguest
• Password:
guest22
• Turn off “enforce
password policy”
Assign user to customers database
• Open Customers
database
• Open Security
• Right-click “Users”
• Select “New User
Assign Roles on Database
• Username and
Login name is
“webguest”
• Assign limited
roles: datareader
and datawriter
Test login
• Create a second
connection to database
in SSMS.
• Login to server using
Sql Server
Authentication
• You now have two
connections to
database. One as an
admin, one as
webguest
Test permissions
• Try to view, add, update,
and delete data
• Try to add a new table
Connect Web to Database
• Create a new file
<%@ Page Language="C#" %>
crud.aspx using
this code
• Replace data
source with your
database name
from Sql Server
Studio
<html>
<head runat="server">
<title>Read Sql Server</title>
<style type="text/css">
table {margin:10px auto; background-color:#fff;}
td {padding:5px;}
body {background-color:#ccc;}
<!DOCTYPE html>
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align:center;">
<h1>Read Sql Server</h1><hr />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="custID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="custID" HeaderText="custID" InsertVisible="False" ReadOnly="True" SortExpression="custID" />
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Data Source=WIN-QDDGT5UI37R;Initial Catalog=customers;User ID=webguest;Password=guest22"
DeleteCommand="DELETE FROM [tblCustomers] WHERE [custID] = @custID" InsertCommand="INSERT INTO [tblCustomers] ([name]) VALUES
(@name)" ProviderName="System.Data.SqlClient" SelectCommand="SELECT [custID], [name] FROM [tblCustomers]"
UpdateCommand="UPDATE [tblCustomers] SET [name] = @name WHERE [custID] = @custID">
<DeleteParameters>
<asp:Parameter Name="custID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="name" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="custID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
Test CRUD
Email links
• Email your Amazon cloud links to Professor Sandvig:
1.
default.aspx
2.
Crud.aspx
Summary
• Today you have:
1.
Logged onto Windows Server
2.
Created a new application pool
3.
Created a new web application
4.
Used Sql Server Management Studio to:
a.
b.
c.
d.
5.
Create a new database
Create a new user
Assign the user to the database
Log in as the new user
Read your database from an .aspx application
Other things you could do:
• Create your own Amazon EC2 instance (free but requires
a credit card)
• Copy your MIS 324 / MIS 424 assignments to Amazon
• Setup a CMS
• Download Microsoft Web Platform Installer
• Select a CMS (see next page)
Web Platform Installer
Say adiós to your instance
• Professor Sandvig will terminate your instance.
• AWS charges about $0.07 per hour for this
instance type
Finished