Solved

How to map windows accounts ?

Posted on 2008-10-24
7
530 Views
Last Modified: 2008-12-06
I want to transfer a database between server A and server B.

On server A I have some sql and windows accounts with user mappings to that database.

I may use the store procedure sp_change_users_login to map sql account but not to map windows accounts.

How map windows accounts ?
0
Comment
Question by:LuisGavinhos
  • 3
  • 2
7 Comments
 
LVL 4

Accepted Solution

by:
ThorSG1 earned 500 total points
ID: 22803826
All of these will work for both domain accounts or sql accounts.  For domain accounts use this format: Domain\username
If you end up with orphaned accounts from Server A  use this:
EXEC sp_revokedbaccess 'username'
This grants access to the database in question.
EXEC sp_grantdbaccess 'username', 'username'
This grants the priviledge level you want to use.

EXEC sp_addrolemember 'db_datareader', 'username'

You can check help for each of these to verify the formating.
0
 

Author Comment

by:LuisGavinhos
ID: 22819800

The sp  sp_change_users_login  at Windows 2005 no longer support mapping windows logins like XXX\XXX. You may read at book online at this sp : "sp_change_users_login cannot be used with windows logins"

I tried and receive the following error : "Terminating this procedure. The User name 'PDGRN\sqladmin' is absent or invalid.

Any idears ?
0
 
LVL 4

Expert Comment

by:ThorSG1
ID: 22822796
I'm not saying to use that stored procedure.
Microsoft suggests not using the sp_grantdbaccess as it will not be supported in future versions.  It will be replaced with the command create user.
So weather you use the sp_granddbaccess or create user those are what you need to use.  You are correct the stored procudure sp_change_users_login will not work for windows accounts.  Both will work with SQL 2005.
Once you use one of the above options I've suggested you can then run the stored procedure sp_addrolemember.  This will grant the user the permissions you want to give them.
Examples:
-- First example is a domain account.  Second example is a sql account.
exec sp_grantdbaccess 'microsoft\jimbob', 'microsoft\jimbob'
exec sp_grantdbaccess 'jimbob', 'jimbob'
--
exec sp_addrolemember 'db_dataowner', 'microsoft\jimbob'
exec sp_addrolemember 'db_datareader', microsoft\jimbob'
exec sp_addrolemember 'db_datareader', 'jimbob'
0
 
LVL 4

Expert Comment

by:ThorSG1
ID: 22907623
Have you had any luck with this issue?
0
 

Author Comment

by:LuisGavinhos
ID: 22916610
I created the accounts manualy and run sp_change_users_login.
Finaly I had no need to create windows accounts.

0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question