Solved

List Orphan User & role  and delete Orphan User who Don't Have sysadmin Role

Posted on 2009-04-10
2
865 Views
Last Modified: 2012-05-06
I am looking for a script that will list orphan user & roles and a script that will delete all orphan users who do not have sysadmin role. This needs to work with SQL Server 2000 & 2005.
0
Comment
Question by:Omega002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 17

Accepted Solution

by:
k_murli_krishna earned 500 total points
ID: 24117418
All of these instructions should be done as a database admin, with the restored database selected.
This will lists the orphaned users:
EXEC sp_change_users_login 'Report'
If you already have a login id and password for this user, fix it by doing:
EXEC sp_change_users_login 'Auto_Fix', 'user'
If you want to create a new login id and password for this user, fix it by doing:
EXEC sp_change_users_login 'Auto_Fix', 'user', 'login', 'password'

Also, refer:
http://www.mssqltips.com/tip.asp?tip=1590
For orphaned role, refer:
http://www.eggheadcafe.com/forumarchives/SQLServerserver/Jun2005/post23408248.asp
 
0
 
LVL 17

Assisted Solution

by:k_murli_krishna
k_murli_krishna earned 500 total points
ID: 24117472
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Job Hung 17 37
Convert time stamp to date 2 57
Sql server Error message 3 16
Need to create and populate a column map table 5 24
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

726 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