Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

P

Pai

Hello there,

I have a .aspx page with the following code in the click event of a
button.

get the following error:

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Code:

string myConnectionString =
"server=testserver;database=MembersCustom;user
id=test;pwd=test;integrated security=true;";

SqlConnection myCon = new SqlConnection (myConnectionString);

string mySqlString = " select * from Cycle_Details";

SqlDataAdapter myCmd = new SqlDataAdapter (mySqlString,myCon);

DataSet my_dataset = new DataSet();

myCmd.Fill (my_dataset,"Cycle_Details");

foreach ( DataTable tb in my_dataset.Tables)
{
foreach ( DataRow rw in tb.Rows)
{
foreach( DataColumn cl in tb.Columns )
{
TextLastName.Text = rw[cl].ToString() ;
}
}

I have added the user test to the logins section under Security
options in the SQL Server and given db_datareader and db_datawriter
roles to the user.

I have also added ASPNET to the same section and given the same rights
for the MembersCustom database

But i still get the error.

This is how the Web.config file looks like:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<system.web>

<compilation
defaultLanguage="c#"
debug="true"
/>

<customErrors
mode="RemoteOnly"
/>

<authentication mode="Windows" />


<authorization>
<allow users="*" /> <!-- Allow all users -->
</authorization>

<trace
enabled="false"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="true"
/>

<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>

<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>

</system.web>

</configuration>

Any help or suggestions...

Kind Regards,
Pai.
 
R

Roman S. Golubin1709176985

Hi, Pai!
I have a .aspx page with the following code in the click event of a
button.

get the following error:

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Since your use windows authentication with integrated security then yuor
must add this user 'NT AUTHORITY\NETWORK SERVICE' to SQL server logins,
database users, table permitions and so...

Otherwise if your want to use sql-server authentication to connect to with
user 'test' then you must set Integrated Security to 'false' :


string myConnectionString = "server=testserver;database=MembersCustom;user
id=test;pwd=test;integrated security=FALSE;";


--
WBR, Roman S. Golubin
ICQ UIN 63253392
(e-mail address removed)

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top