Login Fails

  • Thread starter Thread starter John Carnahan
  • Start date Start date
J

John Carnahan

Why would the login fail to the Northwind database on a web form, but not a
win form?
I'm using the same connection string on the samples... for Masterdetail
examples
in both the Web version, and the Win Forms version.
The Win Form version works but the web form version fails when the
data adapter trys to fill the dataset.

I've tried draging a table from the server explorer to the web form, and all
of the connections, adapters, commands etc are created,
but the connection fails when you try to open it in code.
The IDE will generate the dataset and display the test data however.
 
could have something to do w the aspnet user acount on your pc
could you check if that exists?
 
How are you connecting to the database, with a trusted connection (SSPI)?
If so, I think the only way to do it is via the ASP.NET account, which must
be granter permissions on teh server before it will work.

Othewise, you'll need mixed mode authentication and you'll have to pass in a
valid username and password.

HTH,

Bill
 
If you dragged the connection onto the form, I can tell you exactly why.

By default, .NET uses integrated security. When you use a web app, you are
authenticated, initially, as IUSR_ComputerName, not as yourself. Since IUSR
does not have access to the database, it fails. Note that I am assuming SQL
Server here:

Choices:
1. Hijack the thread to log in with a user that has access
2. Turn off anonymous access (not a good idea with Internet apps)
3. Allow IUSR access to the database (not the most secure idea)
4. Switch to mixed mode security and have a user and password in the conn
string (best to encrypt the string -- nice articles on MSDN on this)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
I am way lost here... and really need some help.
I think this is related to the security fix (broken) on XP net 1.
After you RUN the fix, it breaks the database connections "msde", and when
you run the database connections fix
you break your back trying to figure out why NOTHING works. Gees... two
days spent on such a stupid thing! And I haven't written one line of code
yet...Now that's a RAD tool if I've ever seen one.
COME ON MICROSOFT!

1.) Have the MSSQL that ships with .net 1 ( not the big Sq server...the
little one)
2.) Installed the NetSDK northwind database for the samples.
3.) Before security unpdate, everything worked fine.
4.) After security update , broke the connection on web access. Still can
connect through a win form, and the server explorer though
5.) Ran the FIXUP.exe to fix the XP problem. This fixed the Application
error problem, but not the database connections
6.) On the ASP forum, they said to run the following, but it doesn't work
either...
sign on as administrator
cd C:\Program Files\Microsoft SQL Server\MSSQL$NetSDK\Binn
osql -S (local) -q "exec sp_grantlogin N'MachineName\ASPNET'" -U sa
Password: leave blank and hit enter

--- error Server does not exist or access denied.

NOW WHAT?
 
Yes, there is a ASPNET User account. It says it is password protected, but I
havn't a clue what that is because I never set up a password when .net was
installed.
It says I could change it, but it says I'll loose all kinds of things....I
think I already lost them all....what ever THEM are?
I know that when I ran the FIXUP.exe to fix the securty problem on XP, you
were suppose to type in
1.. Select Run... from the start menu, and enter cmd.exe
2.. In the open command windows, type c:\fixup.cmd.
3.. When prompted, enter 1pass@word as the password.
4.. If you have previously custom access control settings or database
account permissions for the ASPNET account, you'll need to re-apply these
settings now.
I finally found the explanation on what #4 meant above from a ASP forum. but
that didn't work either.

Re: Negative side effect of 'fix'
Posted: 08-28-2003 09:36 PM
For fixing this -
Open a command prompt,
Switch to the BINN dir under your sql installation - this would be
located as follows "\Program Files\Microsoft SQL Server\MSSQL\Binn".
Type in the following command
osql -S (local) -q "exec sp_grantlogin N'MachineName\ASPNET'" -U sa
This will prompt for password, if you had ever set this - enter the
password else leave blank
Next type the following
osql -S (local) -Q "use %MyDB% EXEC sp_grantdbaccess
N'MachineName\ASPNET', N'ASPNET'" -U sa

In the above case replace %MyDB% by the db you want to give aspnet
account access. Also if your msde install is a named instance then use the
(local)\%InstanceName% in place of (local) where %InstanceName% is the
instance name - if it is the default instance then (local) will be fine. For
eg. the name of MSDE instance that installs with the quickstarts is NetSDK

You get an error.... "server not found or access denied "... when you
run the first command line above
 
MSDE is a bitch in some ways, but let's approach this methodically.

1. Open up IIS manager (administration tools)
2. Right click on the site in question and go to properties
3. In the security tab, click the top button and turn off Anonymous Access
4. Try the app

If this works, it is the integrated security that is the problem. You can
now reset the app to its original settings and make a decision. The easiest
direction is to go to mixed mode security.

The easiest way is to start the MSDE install with the flag SECURITYMODE=SQL,
as outlined in this KB:
http://support.microsoft.com/default.aspx?scid=kb;en-us;325022

But, you already have it installed, so going back and running install is a
pain. There is a registry hack outlined in
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q285097

1. Stop SQL Server and all related services, such as SQLAgent, from the
Services control panel.

2. Click Start, click Run, type regedt32, and then click OK.

3. Find the HKEY_LOCAL_MACHINE window on the local computer.

4. Navigate to the following registry key for the default instance:
HKEY_LOCAL_MACHINE\Software\Microsoft\MSSqlserver\MSSqlServer

5. Navigate to the following registry key for a named instance:
HKLM\Software\Microsoft\Microsoft SQL Server\Instance
Name\MSSQLServer\LoginMode

6. On the right-hand pane, find the value LoginMode and double-click it.
7. In the DWORD Editor window, set the value to 0 or 2. Also, make sure that
the Hex radio button is selected.
8. Click OK.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Greg,
Thanks for trying to help,
1. Open up IIS manager (administration tools)
2. Right click on the site in question and go to properties
3. In the security tab, click the top button and turn off Anonymous Access
4. Try the app

This didn't work for me. still won't open the database.

On your notes below, I've also got alot of work into designing my own
database, that I can't get access to anymore. I want to do the right thing
here
so I don't loose any of that.

Boy, I'll tell you.... this security stuff is a real pain in the butt. I'd
almost rather deal with the trouble a hacker would cause than deal with the
problems MS causes with this security stuff.
 
if all else fails (i dont think doing this is good for your securety) log on
as admin and give the aspnet account administrator rights (on the server,
but i think you are doing it all on your pc) thats probably not the ideal
way but i had a similar problem once on a w2k server and that was the only
way we could get it to work (granted were not w2k or sql server experts)

eric
 

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

Back
Top