T
Tony Johansson
Hello!!
I use IIS 5 and SQL Server Express 2005
Acccount ASPNET is used when running IIS to access the SQL Server database.
This account ASPNET get access to the database server by using the
BUILTIN\user login account.
Now if I look at Security->users that have access to the Northwind database
I
can find these four accounts.
dbo
guest
INFORMATION_SCHEMA
sys.
The owner of the Northwind database is Tony.
There is no user called ASPNET under Security->users for the Northwind
database.
Here is quick and dirty code that show how I connect to the northwind
database.
After this code can you see the web.config file
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection sqlConn = null;
try
{
ConnectionStringSettings cs =
ConfigurationManager.ConnectionStrings["NorthwindConnectionString"];
string connString = cs.ConnectionString;
sqlConn = new SqlConnection(connString);
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandText = "select user_name(), current_user";
sqlCmd.Connection = sqlConn;
sqlConn.Open();
string svar = (string)sqlCmd.ExecuteScalar();
Response.Write(svar);
}
catch (Exception)
{
throw;
}
}
web.config file
***********
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;
Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;"
providerName="System.Data.SqlClient" />
<add name="NorthwindConnectionString" connectionString="Data
Source=HEMPC\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<authorization>
<allow users="John"/>
<deny users="?"/>
</authorization>
<authentication mode="Forms">
<forms loginUrl="LoginForm.aspx" timeout="5" cookieless="AutoDetect"
protection="All"/>
</authentication>
<compilation debug="true"/>
</system.web>
</configuration>
Can somebody explain how ASPNET can get access rights to the Northwind
database ?
I don't understand how ASPNET can access the Nortwind database.
//Tony
I use IIS 5 and SQL Server Express 2005
Acccount ASPNET is used when running IIS to access the SQL Server database.
This account ASPNET get access to the database server by using the
BUILTIN\user login account.
Now if I look at Security->users that have access to the Northwind database
I
can find these four accounts.
dbo
guest
INFORMATION_SCHEMA
sys.
The owner of the Northwind database is Tony.
There is no user called ASPNET under Security->users for the Northwind
database.
Here is quick and dirty code that show how I connect to the northwind
database.
After this code can you see the web.config file
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection sqlConn = null;
try
{
ConnectionStringSettings cs =
ConfigurationManager.ConnectionStrings["NorthwindConnectionString"];
string connString = cs.ConnectionString;
sqlConn = new SqlConnection(connString);
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandText = "select user_name(), current_user";
sqlCmd.Connection = sqlConn;
sqlConn.Open();
string svar = (string)sqlCmd.ExecuteScalar();
Response.Write(svar);
}
catch (Exception)
{
throw;
}
}
web.config file
***********
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;
Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;"
providerName="System.Data.SqlClient" />
<add name="NorthwindConnectionString" connectionString="Data
Source=HEMPC\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<authorization>
<allow users="John"/>
<deny users="?"/>
</authorization>
<authentication mode="Forms">
<forms loginUrl="LoginForm.aspx" timeout="5" cookieless="AutoDetect"
protection="All"/>
</authentication>
<compilation debug="true"/>
</system.web>
</configuration>
Can somebody explain how ASPNET can get access rights to the Northwind
database ?
I don't understand how ASPNET can access the Nortwind database.
//Tony