Finding all mappings of a SQL Server Login Name
Posted Under: Uncategorized
These days I am researching on SQL Server undocumented features and I am planning to compile a list undocumented functions, DBCC commands, undocumented stored procedures etc. Today I am sharing you a very useful undocumented stored procedure called sp_MSloginmappings. This stored procedure takes one optional parameter @loginname which you may already guessed is the Login Name.
sp_MSloginmappings lists down all the mappings of the given login name. If you do not provide a Login Name, then it will iterate all Login names and will list down their user name mappings in all databases. It is an excellent undocumented feature to find out all the mappings of a given login name.
Following is an example usage of this stored procedure:
exec master..sp_MSloginmappings ‘NT AUTHORITY\NETWORK SERVICE’




