Link to home
Start Free TrialLog in
Avatar of dotntlearner
dotntlearner

asked on

How to authenticate C#.net windows application using SQL Server 2008 service accounts?

I have a windows application in C#.net.
Right now I am authenticating the users by adding them to sql table which checks what access access the user has and adding them to the group I created in LOCAL USERS AND GROUPS in COMPUTER MANAGEMENT.
I want change it to something like authenticating the users from SQL Server 2008.
Based on this authentication they can have read only access/ access to only particular tabs/ all of the application. I think I use SQL Server Service accounts for this.
But not sure how I can do it.
Can anyone please help.
Avatar of nost2
nost2

In the connection string to SQL Server, set Trusted_Connection to True to log in as a windows user. In SQL Server you can give permissions to windows users or groups on tables. Service accounts are used for running SQL Server, this is not what you would use here. The alternative to windows users is database users, then you must set Trusted_Connection to False in the connection string and specify user name and password.
Avatar of EugeneZ
create \or use existing NT Group: add the specific users login there;
add this nt group (e.g. yourdomainName\YourUsersGroup) to the your sql server logins; add this new login as DB user and  grant read only access/ access to only particular tabs/
ASKER CERTIFIED SOLUTION
Avatar of EugeneZ
EugeneZ
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dotntlearner

ASKER

I created SQL server login like according to the steps shown in this video.
http://www.youtube.com/watch?v=NesTvOYsVaM 

Below is the connection string I am using
"Server=SERVERNAME\\SQLSERVERINSTANCE;Database=DATABASENAME;Trusted_Connection=False;connection timeout=600;User ID=SQLLOGIN;Password=PASSWORD"
It throws an exception that "Login failed for user."
is the login

can you login on your sql server via SSMS as this SQLLOGIN;Password=PASSWORD"?

also try an another connection string
http://www.connectionstrings.com/sql-server-2008


and I see named  instance name has 2 \ "\\"

SERVERNAME\\SQLSERVERINSTANCE

try just SERVERNAME\SQLSERVERINSTANCE
I forgot to change the authentication from Windows to SQL at server level. It worked after I changed it.
Thanks.