Do not use on any
shared computer
August 29, 2008 09:07pm pdt
 
[x]
Attachment Details

Create user account in SQL server 2005

Tags: sql, user, 2005, server, create
hell there,

i am having problem viewing reporting service reports i created.i get this error.how do i create a user with a trusted SQL Server connection.

the error i get is.but in my studio i see that user 'ReportExecution'.

An error has occurred during report processing.
Cannot create a connection to data source 'rs2005sbsDW'.
Login failed for user 'ReportExecution'. The user is not associated with a trusted SQL Server connection.



when i run this sql script

DECLARE @PermissionString nvarchar(255)
DECLARE @AWSalesDirector nvarchar(200)
DECLARE @SalesAnalyst nvarchar(200)

SET @AWSalesDirector = @@SERVERNAME + '\AWSalesDirector'
SET @SalesAnalyst = @@SERVERNAME + '\SalesAnalyst'

--drop the users from the database
use rs2005sbsDW
if exists(select * from sysusers where name='ReportExecution')
      exec sp_dropuser @name_in_db='ReportExecution'
if exists(select * from sysusers where name=@AWSalesDirector)
      exec sp_revokedbaccess @name_in_db=@AWSalesDirector      
if exists(select * from sysusers where name=@SalesAnalyst)
      exec sp_revokedbaccess @name_in_db=@SalesAnalyst

use rs2005sbs
if exists(select * from sysusers where name='ReportExecution')
      exec sp_dropuser @name_in_db='ReportExecution'
if exists(select * from sysusers where name=@AWSalesDirector)
      exec sp_revokedbaccess @name_in_db=@AWSalesDirector      
if exists(select * from sysusers where name=@SalesAnalyst)
      exec sp_revokedbaccess @name_in_db=@SalesAnalyst

use msdb
if exists(select * from sysusers where name='ReportExecution')
      exec sp_dropuser @name_in_db='ReportExecution'
if exists(select * from sysusers where name=@AWSalesDirector)
      exec sp_revokedbaccess @name_in_db=@AWSalesDirector      
if exists(select * from sysusers where name=@SalesAnalyst)
      exec sp_revokedbaccess @name_in_db=@SalesAnalyst

use ReportServer
if exists(select * from sysusers where name='ReportExecution')
      exec sp_dropuser @name_in_db='ReportExecution'
if exists(select * from sysusers where name=@AWSalesDirector)
      exec sp_revokedbaccess @name_in_db=@AWSalesDirector      
if exists(select * from sysusers where name=@SalesAnalyst)
      exec sp_revokedbaccess @name_in_db=@SalesAnalyst

--create the logins
use master
exec sp_droplogin @loginame='ReportExecution'
exec sp_addlogin @loginame='ReportExecution', @passwd='ReportExecutions'

exec sp_revokelogin @loginame=@AWSalesDirector
exec sp_grantlogin @loginame=@AWSalesDirector

exec sp_revokelogin @loginame=@SalesAnalyst
exec sp_grantlogin @loginame=@SalesAnalyst

use rs2005sbsdw
--add the users to the databases and give them permissions
exec sp_adduser @loginame='ReportExecution', @grpname='db_datareader'
exec sp_grantdbaccess @AWSalesDirector, @AWSalesDirector
exec sp_addrolemember 'db_datareader', @AWSalesDirector
exec sp_grantdbaccess @SalesAnalyst, @SalesAnalyst
exec sp_addrolemember 'db_datareader', @SalesAnalyst
GRANT EXECUTE ON sp_ActualVsQuota TO ReportExecution
SELECT @PermissionString = 'GRANT EXECUTE ON sp_ActualVsQuota TO [' COLLATE Latin1_General_CI_AS + @AWSalesDirector + ']' COLLATE Latin1_General_CI_AS
EXEC (@PermissionString)

use rs2005sbs
--add the users to the databases and give them permissions
exec sp_adduser @loginame='ReportExecution', @grpname='db_datareader'
exec sp_grantdbaccess @AWSalesDirector, @AWSalesDirector
exec sp_addrolemember 'db_datareader', @AWSalesDirector
exec sp_grantdbaccess @SalesAnalyst, @SalesAnalyst
exec sp_addrolemember 'db_datareader', @SalesAnalyst

use msdb
--add the users to the databases and give them permissions
exec sp_adduser @loginame='ReportExecution', @grpname='db_datareader'
exec sp_grantdbaccess @AWSalesDirector, @AWSalesDirector
exec sp_addrolemember 'db_datareader', @AWSalesDirector
exec sp_grantdbaccess @SalesAnalyst, @SalesAnalyst
exec sp_addrolemember 'db_datareader', @SalesAnalyst

use ReportServer
--add the users to the databases and give them permissions
exec sp_adduser @loginame='ReportExecution', @grpname='db_datareader'
exec sp_grantdbaccess @AWSalesDirector, @AWSalesDirector
exec sp_addrolemember 'db_datareader', @AWSalesDirector
exec sp_grantdbaccess @SalesAnalyst, @SalesAnalyst
exec sp_addrolemember 'db_datareader', @SalesAnalyst



i get this error-------

Changed database context to 'rs2005sbsDW'.
Changed database context to 'rs2005sbs'.
Changed database context to 'msdb'.
Changed database context to 'ReportServer'.
Changed database context to 'master'.
Msg 15007, Level 16, State 1, Server ZJAFFERI, Procedure sp_droplogin, Line 26
'ReportExecution' is not a valid login or you do not have permission.
Msg 15151, Level 16, State 1, Server ZJAFFERI, Line 1
Cannot drop the login 'ZJAFFERI\AWSalesDirector', because it does not exist or you do not have permission.
Msg 15151, Level 16, State 1, Server ZJAFFERI, Line 1
Cannot drop the login 'ZJAFFERI\SalesAnalyst', because it does not exist or you do not have permission.
Changed database context to 'rs2005sbsDW'.
Changed database context to 'rs2005sbs'.
Changed database context to 'msdb'.
Changed database context to 'ReportServer'.
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Microsoft
Question Asked By: zolf
Solution Provided By: rk_india1
Participating Experts: 1
Solution Grade: A
Views: 431
Translate:
Loading Advertisement...
 
[+][-]Accepted Solution by rk_india1
Accepted Solution by rk_india1:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628