Can't open database in browser control

P

Parrot

I cannot access my SQL database in a browser control created in my C# Windows
application program I can, however, access the database from an IE browser.
I get the ubiquitous "Login failed for NT AUTHORITY\NETWORK SERVICE" error
message. I researched all the advice on the internet and tried to add an NT
AUTHORITY\NETWORK SERVICE login to my database under the Security/Users tab
using SQL Server Mangement. However, there is no NT AUTHORITY\NETWORK SERVICE
login in my SQL dialog, only an NT AUTHORITY\SYSTEM login. Why is that?
Secondly, I finally was able to add an NT AUTHORITY\NETWORK SERVICE manually
to my database login and gave it all of the permissions but I still get the
error when accessing the database through my Windows browser control.
Below is my connection string.

Provider=SQLOLEDB; Data Source=Vista; Initial Catalog=Mydatabase;Integrated
Security=SSPI";

Dave
 
S

sloan

You always need to know and be aware of the account you're running under:

Here is some crappy debugging code.

I think the issue is you don't have sql server credentials for the user the
program is running under.

Go to Control Panel / Users and you can see a list of "built in" users that
a windows machine has.



private string FindIIdentity()

{

try

{



string returnValue = string.Empty;

WindowsIdentity ident = WindowsIdentity.GetCurrent();

returnValue = ident.Name;

try

{

returnValue += " on " + System.Environment.MachineName;

}

catch (Exception ex)

{

}

return returnValue;

}



catch (Exception ex)

{

return "Error Finding Identity";

}

}
 
P

Parrot

Thanks for your reply. I inserted your debug code and determined that my
user login was Vista\Dave under VISTA. I add Vista\Dave as a user for my
database and giving it full permission and reran my application and I still
get the NT AUTHORITY error. There has to be something to with the browser
control as I don't get this error in my other Window dialogs in this
application.
Dave
 
S

sloan

Yammers.

I don't know then.


My last check would be:

Security / Logins
Databases / MyDatabase / Security / Users


Those are 2 different things in Sql Server.

Now, when you create the login, and ALSO ADD THE "MyDatabase", the "user"
will be auto created.

But I'd check both of those places.


But I don't know. At least you know which user is trying to access the db
under the integrated model.
 
P

Parrot

It really doesn't make any sense. I am getting an error on a login for NT
AUTHORITY yet my Window Identity is Vista\Dave. I think the only way I can
get around it is to provide a user id and password in my connection instead
of using the Integrated Security=SSPI. Looks like a bug to me but I can't
believe I am the only person with this problem.
Dave
 
H

Hans Kesting

Thanks for your reply. I inserted your debug code and determined that my
user login was Vista\Dave under VISTA. I add Vista\Dave as a user for my
database and giving it full permission and reran my application and I still
get the NT AUTHORITY error. There has to be something to with the browser
control as I don't get this error in my other Window dialogs in this
application.
Dave

Is this "Vista" (from "Vista\Dave") a domain or your local machine?

If it is a domain, does your database server have access to the same
domain?

If it is your local machine, then that database server will not know
about that account. Best to use SqlServer login then (which you need to
enable explicitly in SqlServer as it is disabled by default). You will
need to specify username and password in your connectionstring.

Hans Kesting
 
P

Parrot

The problem is on my local machine and I agree that the only way out of this
problem is to use a user id and password in my connection string. It's not
want I want to do as that requires more programming maintenance but I don't
see any other way around this problem. In summary, I feel this problem is a
bug in disguise and has wasted an awful lot of my time and others trying to
find a solution to something that should be simple.
Dave
 

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