(无题)
未识别博客 · mill2002 · 2004-05-14
2004-05-14
Login Failed: Reason:.... help plz!
Login Failed: Reason:.... help plz!
Posted:
18 Feb 2004 05:09 PM
Hello! I've tried to solve this problem for two days now so i guess i need some advice.
I've installed the ibuyspy store and when i try to access it on the local machine i got the
error message telling me i canät log in, then i changed the line in web.config to
<add key="ConnectionString" value="server=servername;uid=userid;pwd=passwd;database=dbname" />
and got a new error, this:
Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
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 'sa'. Reason: Not associated with a trusted SQL Server connection.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +472
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
IBuySpy.IBuySpy.ProductsDB.GetProductCategories() +96
IBuySpy.C_Menu.Page_Load(Object sender, EventArgs e) +127
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +731
and i have this problem with multiple projects (other store projects, e-forum etc)
can't solve it... i would be grateful for any advice
thx /Daniel
R-man
Joined:
06 Feb 2004
Total Posts:
9
Re: Login Failed: Reason:.... help plz!
Posted:
19 Feb 2004 05:26 AM
Hi.
Please check
http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=345386
MSDN library and MSSQL server "Books on-line" could help also.
Regards.
bcross75
Joined:
26 Nov 2003
Total Posts:
10
Re: Login Failed: Reason:.... help plz!
Posted:
20 Feb 2004 07:29 AM
This post tells how to add and grant privilages for a new "<LocalHost>/AHEM" User in a new database, using SQL Enterprise Manager.
Can you tell us how to do this using OSQL ?
R-man
Joined:
06 Feb 2004
Total Posts:
9
Re: Login Failed: Reason:.... help plz!
Posted:
20 Feb 2004 11:41 AM
As far as I remember, there are two possible ways to do it.
1. using sp_addlogin stored procedure.
2. using sp_grantlogin and sp_grantdatabase.
The first one - creating new SQL Server account, the second - grant access to the Server for WINNT user (windows authentication will be used).
Execute osql -E -S ServerName.
Logon as SA user.
EXEC sp_addlogin 'loginname', 'password', 'databasename'
login should be just a name without a <computer name>
That's it. In this case it would not be a trusted connection and you will have to modify webconfig.cfg file
Or
EXEC sp_grantlogin 'login'
EXEC sp_grantdbaccess 'login', 'database_name'
login could be in a form <Computer name>\Username.
This one will create trusted connection for WINNT user.
I guess that's it.
Please check MSDN library for details if something is unclear.
Regards,
R-man.
bcross75
Joined:
26 Nov 2003
Total Posts:
10
Re: Login Failed: Reason:.... help plz!
Posted:
20 Feb 2004 12:08 PM
Thanks R-Man! Here is a little HOW TO ... I put together, for my next new database.
ASP NET Database Access Privileges for ASP.NET Framework Applications
===============================================
Granting Login Access to user AHEM\ASPNET should not be necessary and already exist if you have a sample/quick start application up and running like, Portal, TimeTracker, etc.
FOR NEW DATABASES YOU'VE CREATED AND WANT TO ACCESS THROUGH an
ASPNET Sample App (like a new Portal Module, for example):
STEP: ONE
=======
In (web.config) find appSettings group AND for each new database, add:
- unique connectionstring key (~NewConnStrKeyName~)
- new database (~NewDBName~)
Example:
- Find this..
<appSettings>
<add key="ConnectionString" value="server=localhost;Trusted_Connection=true;database=Portal" />
- Add this---(substitute your connect string and database names where indicated)
<add key="~NewConnStrKeyName~" value="server=localhost;Trusted_Connection=true;database=~NewDBName~" />
--------------------------------------------------------------
STEP: TWO
========
Either use Enterprise SQL Manager or OSQL to:
a)- (Add)/Grant Access for user ASPNET to your new Database (~NewDBName~)
b)- (Add)/Grant Owner Role to Role Memberships for user ASPNET to your new Database (~NewDBName~)
OSQL Example:
1) Start - Run - type CMD - Press Enter
2) Grant User Access to new Database (~NewDBName~)
At the Command Prompt, Type and Enter:
osql -E -S (local) -d ~NewDBName~ -Q "sp_grantdbaccess '~YourMachineName~\ASPNET'"
3) Add Owner Role Membership to ASPNET for your new database:
At the Command Prompt, Type and Enter:
osql -E -S (local) -d ~NewDBName~ -Q "sp_addrolemember 'db_owner', '~YourMachineName~\ASPNET'"
This should make your Login/Access Errors go away!
Hope this helps
Previous Thread
::
Next Thread
Page 1 of 1
ASP.NET Forums
>
Source Discussions
>
IBuySpy Store
>
Login Failed: Reason:.... help plz!
Copyright 2003 Microsoft Corporation
Privacy Statement
|
Visit our Hoster: OrcsWeb
Questions/Problems
mill2002
引用Trackback(0)
|
编辑
评论
Hi.
Connecting to the database using "sa" account, is not very good idea, IMHO. Because it is very unsafe.
There is another way to solve connection problem.
1. Create computer_name/ASPNET user. In my case it was SERVER/ASPNET.
2. In SQL Enterprise manager, open STORE database and open USERS folder there.
You have to add computer_name/ASPNET as new user for the STORE database and grant "public" and "dbo" privileges for computer_name/ASPNET user.
3. Connect to the database using Trusted connections, like it is described in IBuySptStore tutorial.
Regards, R-Man.
R-man
(
发表评论
用户名:
Email:
主页:
最后更新
斑竹,为什么备份数据的格式是htm的,而不是xml的呢?偶的分类目录及友情联结都无法保存啊
scottwater.com/blog/
weihua ju
xml programming for .Net 的书那一本好?
程序员驿站
Login Failed: Reason:.... help plz!
mq_1980
Login Failed: Reason:.... help plz!
用VS.NET打开书中的WEB窗体例子时遇到的错误,大侠指教.
大侠指点:VS.NET无法打开应用程序,提示说很可能是本地WEB服务器上没有安装所需的组件.
原始快照:web.archive.org