andycharger Posted July 1, 2003 Posted July 1, 2003 Hi. Im trying to connect to my SQL SERVER database and im having some troubles. I get the following message when I press a button on an ASP form to connect. Server Error in '/inet1' Application. -------------------------------------------------------------------------------- Login failed for user 'ADMINIT1\ASPNET'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'ADMINIT1\ASPNET'. Source Error: Line 51: Dim cnSQL As New SqlConnection() Line 52: cnSQL.ConnectionString = strSql Line 53: cnSQL.Open() Line 54: Line 55: End Sub Source File: c:\inetpub\wwwroot\inet1\logon.aspx.vb Line: 53 Stack Trace: [sqlException: Login failed for user 'ADMINIT1\ASPNET'.] System.Data.SqlClient.SqlConnection.Open() inet1.logon.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\inet1\logon.aspx.vb:53 System.Web.UI.WebControls.Button.OnClick(EventArgs e) System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain() So there seems to be a problem with my access to the database. I thought i had al lof the permissions set. Can anyone shed any lights as to what it may be. Quote
Administrators PlausiblyDamp Posted July 1, 2003 Administrators Posted July 1, 2003 Although you as a user may have permissions to the database, by default ASP.Net applications will attempt to connect as the account ASPNET. You either need to give this user permissions to the database or look at getting the WebApp to impersonate the calling user. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
andycharger Posted July 1, 2003 Author Posted July 1, 2003 A genius you are! that user, ASPNET, I dont know where it has come from. Can you tell me how I find it and give it permissions? Do all applications built in .NET use this login access?(ASPNET) Any help would be appreciated. Quote
Administrators PlausiblyDamp Posted July 1, 2003 Administrators Posted July 1, 2003 All ASP.Net applications execute as the user ASPNET, it is created as part of the framework installation. You can give it permisions to the database through SQL Enterprise manager Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
JABE Posted July 1, 2003 Posted July 1, 2003 This is one of the most popular problems I've ever read in newsgroups. I wonder if anyone knows if there's a KB article (or any other link for that matter) that enumerates a step-by-step troubleshooting guide for this problem. Quote
*Experts* Nerseus Posted July 2, 2003 *Experts* Posted July 2, 2003 It's not really troubleshooting, it's just knowing the basics of SQL Server administration. If you're a normal developer, you setup SQL Server on your own box and you log in as "sa" with no password. That's the default user/pass during setup (though you have to bypass a warning about the sa password being blank). The problem you might be having is if your SQL Server install is only allowing SQL Server userid/password to log in. I don't have SQL Server on this machine (I can look in the morning), but you'll want to check the server settings/options. Look for something about mixed security. You WANT mixed security. It means SQL Server logins can either be username/password created ONLY in SQL Server (managed through enterprise manager) or an NT/Win2000 userid/password (your domain account). If your SQL Server only allows SQL Server uid/pwd to login (which is how the sa account is created), you'll need to change it. Once you're sure SQL Server allows mixed authentication, you'll want to make sure the ASPNET user (just like your username) has permissions to the Server and database. In enterprise manager, go to the Logins (or is it Security) node in the tree. See what accounts show up. If you don't see: ADMINIT1\ASPNET then you'll have to add. Right click on the tree and select Add new user then make sure it's set for Windows Authentication and choose the user (or paste in the name). Now assign that user some level of permissions to certain databases (or however you want your security to work). I believe the .NET documentation is limited in it's descriptions of setting up the ASPNET user account to have permissions to a database since it's not really a .NET thing, but a SQL Server permissions issue. Keep in mind that the ASPNET account is JUST a regular windows account like your username or your boss's. It just gets created automatically so you can keep track of what permissions your website has (including access to your database). -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.