Executing the following sql:
USE [WSS_Content]
EXEC sp_helplogins
returns two result sets, and within the second resultset I get several rows but one in particular which looks like this:
LoginName DBName UserName UserOrAlias
DEMO\SPUser SharePoint_Config SharePoint_Shell_Access MemberOf
This is as expected, and what I want to see. However executing the following sql:
EXEC sp_helprole 'SharePoint_Shell_Access'
gives me an error which says: ‘SharePoint_Shell_Access’ is not a role. But it is! I can see that it is from SQL Server Management Studio and it even shows me the role’s members from right there.
Ideally what I’m trying to accomplish is to be able to use this:
SELECT IS_MEMBER('SharePoint_Shell_Access')
but of course, this returns null because it also thinks that is not a valid role when it most definitely is. What gives, and how do I best query to see if a given user (or the current user) is a member of this custom database role?
I am running SQL Server 2008 R2.
As it turns out, sp_helplogins returns results across all databases. Which is why that role was showing up when it shouldn’t have if it were limited to the current db like I previously thought.
For whatever reason I just didn’t notice that and thought that entry was applicable to the WSS_Content. Instead it was from the SharePoint_Config database. The error was correct after all and there was no role by that name on the database where I was looking. I was just getting it confused.