top of page
Writer's pictureKunal Ranpura

Script to Fix Orphan Users in SQL Server

Updated: Jan 20, 2020

--Find Orphan Users in the DB

EXEC sp_change_users_login 'Report'

--If you already have a login created, map the user to login using the following script.

EXEC sp_change_users_login 'Auto_Fix', 'user'

--If you want to create a new login and password for this user, fix it by doing:

EXEC sp_change_users_login 'Auto_Fix', 'user', 'login', 'password'

--get info about what AD groups the user is associated with.

xp_logininfo 'Domain\UserName','all'

83 views0 comments

Recent Posts

See All

SQL Server Profiler Trace

--Import multiple trace file in sql Table. --All the rollover files will be automatically imported --provide number tracefile to capture...

Find All Primary Key in SQL Server

select schema_name(tab.schema_id) as [schema_name], pk.[name] as pk_name, substring(column_names, 1, len(column_names)-1) as [columns],...

SQL Server find Database User Permission

--Execute the following script against the User Database where you need to find DB User permission. DECLARE @sql VARCHAR(2048) ,@sort INT...

Comments


bottom of page