Solved

ASP.NET ERROR

Posted on 2004-10-08
12
1,070 Views
Last Modified: 2012-06-21
CAN SOMEONE POINT OUT A SOLUTION TO THIS ERROR? THANKS


mY ERROR

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'SERVXJ-888777\ASPNET'.

Source Error:


Line 299:
Line 300:        ' Set a pointer to the data table
Line 301:        SqlDataAdapter1.Fill(AuthorsDataSet) >>>>> IT POINTS TO THIS LINE
Line 302:        dt = AuthorsDataSet.Tables("Authors")
Line 303:
 
Stack Trace:


[SqlException: Login failed for user 'SERVXJ-888777\ASPNET'.]
   System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
   System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
   System.Data.SqlClient.SqlConnection.Open()
   System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
   System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
   VSM072004.DataGridExample.BindDataGrid() in C:\HTTP\vsmag\vs0409\vs0409do\DataGridExample.aspx.vb:301
   VSM072004.DataGridExample.Page_Load(Object sender, EventArgs e) in C:\HTTP\vsmag\vs0409\vs0409do\DataGridExample.aspx.vb:174
   System.Web.UI.Control.OnLoad(EventArgs e)
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Page.ProcessRequestMain()
0
Comment
Question by:zachvaldez
  • 5
  • 2
  • 2
  • +3
12 Comments
 
LVL 9

Expert Comment

by:Rodney Helsens
ID: 12263081
It seems obvious but... The exception details seem to say it all
Login failed for user 'SERVXJ-888777\ASPNET'.

Take a look at your connection string and determine if the user and password you are using are valid credentials on Sql Server.
0
 
LVL 18

Expert Comment

by:tusharashah
ID: 12263090

You need to give Read\Write Access to User: 'ComputerName\ASPNET' for your Database

-tushar
0
 

Author Comment

by:zachvaldez
ID: 12263109
HOW TO GIVE Read\Write Access to User: 'ComputerName\ASPNET' for your Database? Appreciate  it..
0
 
LVL 18

Accepted Solution

by:
tusharashah earned 125 total points
ID: 12263227
Go to SQL Enterprise Manager -> Your Server -> Your DataBase -> Users

Right Click 'Users' & Add New Database user
Login Name: & User Name: SERVXJ-888777\ASPNET (Give db_datareader & db_datawriter access atleast)

-tushar
0
 
LVL 6

Expert Comment

by:ryerras
ID: 12264263
There is an easy way. If you can show me your connection string, i can tell you wht the problem is. But make sure you have, 'Trusted_Connection=true;' as part of your connection string, then you do not have to create an account for the ASPNET user
0
 
LVL 9

Expert Comment

by:hismightiness
ID: 12264986
Although it will cause more work at the DB level, it is better to create a user account at the SQL Server (from a security standpoint).  This allows for you to explicitly assign permissions for the account being used by your connection string.  This way, if your application is comprimised, your DB is still a bit safer.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 10

Expert Comment

by:jnhorst
ID: 12265419
Your connection string probably has "Integrated Security=SSPI".  The best way to handle this is to do the following:

In Web.config add the following: <identity impersonate="true" />

When you do this, the code that is attempting to connect to the DB will do so under the account that is used to authenticate the request.  If you are allowing anonymous users to request pages, open your IIS admin utility, right click the website and show the Properties.  Select the Directory Security tab and click the Edit button for the first section, which is authentication for anonymous requests.  You'll see that a local account named IUSR_<machine  name> is set to authenticate anonymous reqeusts.  By putting the above tag in web.config, you are telling ASP.NET to use this account to authenticate the request.  If you do not have the above tag, the ASPNET account will be used.  Ideally, the ASPNET account should have as few privileges as possible, so it's best to leave it as it is unless absolutely necessary.  By using Integrated Security=SSPI in your connection string (which is a good idea), SQL Server is receiving its request under the context of either the ASPNET or the IUSR_... account, depending on whether or not you have the <identity> tag as described above.

The best way to address this issue is to create a domain or Active Directory account that will be used exclusively by IIS for authenticating anonymous reqeuests and then reset the IIS setting to use this new account.  Then add that account to your SQL Server Logins and add the login as a user on the database in question.  That will solve the database access issue.

The reason this is the best solution is that if you need to access shares on the network, all you have to do is grant that same account persmissions on the share(s) in question.  Granting local accounts (like ASPNET or the IUSR_<machine name> account) will lead to failures later on if you upgrade server machines.

John
0
 

Author Comment

by:zachvaldez
ID: 12267938
Someone suggested about Trusted Connection to be added   hence  this connection string is:

workstation id=SERVXJ-888777;packet size=4096;integrated security=SSPI;data source="SERVXJ-888777\SERVXJ-888777";persist security info=False;initial catalog=pubs

0
 

Author Comment

by:zachvaldez
ID: 12267973
John,
what specific section in the web config this should  go..
In Web.config add the following: <identity impersonate="true" />
0
 

Author Comment

by:zachvaldez
ID: 12268073
I stil get the error even if I add the user: 'SERVXJ-888777\ASPNET'.
0
 
LVL 10

Expert Comment

by:jnhorst
ID: 12268173
Right after:

<authentication mode="Windows" />

If you have the ability to do so, you'll be far better off creating an account and resetting IIS to use it for anonymous auth, and the add it to the SQL Server.

If you put the tag above in web.config already, then you should add SERVXJ-888777\IUSR_SERVXJ-888777 and see if it works, as that is the default account for anonymous auth.

John


0
 

Author Comment

by:zachvaldez
ID: 12268289
Adding the ASPNET user in the security plus other steps I'd never remembered magically run the project!!
Keep on hustling I guess!!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now