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.
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.
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.
create \or use existing NT Group: add the specific users login there;
add this nt group (e.g. yourdomainName\YourUsersGr oup) to the your sql server logins; add this new login as DB user and grant read only access/ access to only particular tabs/
add this nt group (e.g. yourdomainName\YourUsersGr
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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\\SQLSER VERINSTANC E;Database =DATABASEN AME;Truste d_Connecti on=False;c onnection timeout=600;User ID=SQLLOGIN;Password=PASSW ORD"
It throws an exception that "Login failed for user."
http://www.youtube.com/watch?v=NesTvOYsVaM
Below is the connection string I am using
"Server=SERVERNAME\\SQLSER
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\\SQLSERVERINSTA NCE
try just SERVERNAME\SQLSERVERINSTAN CE
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\\SQLSERVERINSTA
try just SERVERNAME\SQLSERVERINSTAN
ASKER
I forgot to change the authentication from Windows to SQL at server level. It worked after I changed it.
Thanks.
Thanks.