views:

36

answers:

2

Hi,

I have written a Windows service to send mails to users in a Sharepoint list based on some condition.

The development server is a stand-alone Sharepoint installation and the Windows service works fine. But,the Production environment has the application(Sharepoint) and Database(SQL) residing on different servers.

So when the Windows service tries to open the list it says " Cannot open database "WSS_Content80" requested by the login. The login failed." Pease let me know how to proceed.I am struck with this issue for a long time now..

+1  A: 

To solve the Issue quick and Dirty way what you can do is grant permission to the Content Database of your SharePoint application for the User in Which Windows Services Run.

But you want to do it in a neat way I recommend you to write a Timer Job for SharePoint. Here not only does the Permission is taken care automatically but you can also deploy it to multiple Web Application if you want it and manage it easily.

The Best Article on the Subject is here MSDN or AC Article.

Kusek
A: 

Another possible answer is to check which account your service is running as. Running it as a more privileged user like the account that is acting as your app pool would work.

Another possible tact is to look into SPSecurity.RunWithElevatedPrivledges method.

Mark Mascolino