Click to See Complete Forum and Search --> : permission problems with sql server


pgugel
April 29th, 2003, 03:26 PM
I'm having problems with connecting and executing Select statements while trying to learn ado.net. First, I wasn't able to connect because I didn't have a user named 'DUDE/ASPNET'. I created that, then I couldn't get data. The following is the error that occurred:

SELECT permission denied on object 'Contact Types', database 'Contacts', owner 'dbo'.

If anyone can help me straighten out my permissions problems I would greatly appreciate it.

Thanks

pgugel
May 20th, 2003, 08:01 PM
This is apparently no longer a problem. A few weeks ago I tried to give as much permission to all users as possible with no luck. Then, the other day I came back to this project, and it connected to the database no problem. I guess it fixed itself!?:confused:

hellomadhu
May 21st, 2003, 04:33 AM
check out the user rights on ur database. give necessary rights to the ASPNET user account.

womalley
May 25th, 2003, 10:18 AM
Originally posted by hellomadhu
check out the user rights on ur database. give necessary rights to the ASPNET user account.

BEFORE YOU DO THAT!!

Make sure that you are using Windows Authentication.
Then before you open the database use this code

System.Security.Principal.WindowsImpersonationContext userID;
userID = ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();

this.connection.open();
this.connection.close();
userID.Undo();


Because of how ASP.NET works if you dont tell it what permissions to use it will try to use the default ASP.NET account. This is what is causing you permission problem. The above code will let ASP.NET use your account information to open the database. Giving the ASP.NET account a lot of access may not be the best idea.. lol

hope this helps
Will