Sharepoint custom aspx page can't connect to database
I have created a custom aspx page within my Sharepoint site with a SQL Server connection to a database on that server to select data. When I 开发者_JAVA百科view the page it works, but when another user tries to view it it gives the following error :
Server Error in '/' Application.
Login failed for user 'GRINCOR\GuguK'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'GRINCOR\GuguK'.
Can someone give me a solution to this problem? I am using Sharepoint Services 3.0.
From what I can see you can't login on your Database.
Login failed for user 'GRINCOR\GuguK'
This means that the user with Name Guguk can't login.
Maybe you're using Integrated security in your connection string and perhaps you should go with specified credentials instead of having to grant every user who might access the page with permissions in the database.
I would do following:
- Create an Active Directory Group with all users that should have access to the SharePoint Site
- Add this Group to the SharePoint Site with appropriate privileges (Member)
- Add this Group to the MS SQL Server database with appropriate privileges (db_writer?)
I have not tested but I think it should work. It also simplifies the management of the users because you have a central point where you manage users (Active Directory)
Granting Access to a SharePoint page is completely different then granting access to a database.
For the sharepoint page, you have to modify user privileges under "people and groups". Since you mentioned this is a completely custom aspx page, I'm assuming you have it in the _layouts folder in which anybody who has access to your sharepoint site already has permissions to view the page.
For your database, I agree with above. Create a SQL user and use that user in the connection string to the database. This way, no matter who logs into sharepoint they will be using your sql user as credentials for database information.
精彩评论