Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to determine SQL Security Login group for windows login when user is member of active directory security group. Expand / Collapse
Author
Message
Posted Wednesday, May 23, 2007 12:29 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 17, 2014 11:01 PM
Points: 6, Visits: 180

My users login to SQLServer through Active Directory security group memberships.  These groups are security groups in SQLServer and used to assign permissions to database objects.

My problem is that when I query system_user, current_user, suser_sname and user I get the individual user, not the group they are a member of.

So where they login in through 'DOMAIN\SecurityGroup' I get back 'DOMAIN\UserName'

When I try User_ID and user_name I get back the SQLServer role like 'dbo' and 'public'.

How can I detemine which 'DOMAIN\SecurityGroup' is being used by 'DOMAIN\UserName' to access the database.

 

 

 

 

Post #368179
Posted Thursday, May 24, 2007 3:04 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, October 22, 2014 4:18 AM
Points: 2,886, Visits: 3,256
If the user is a member of a DOMAIN\SecurityGroup that has Sysadmin authority in SQL, then that will be used when accessing databases.  Otherwise you need to look at what DOMAIN\SecurityGroup(s) have ben given authority in each database.  If the user is a member of 2 SecurityGroups, with SecGroupA having select authority and SecGroupB having insert authority, then the user can select and insert.

Original author: SQL Server FineBuild 1-click install and best practice configuration of SQL Server 2014, 2012, 2008 R2, 2008 and 2005. 18 October 2014: now over 31,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Concept: "Pizza Apartheid" - the discrimination that separates those who earn enough in one day to buy a pizza if they want one, from those who can not.
Post #368567
Posted Thursday, May 24, 2007 5:04 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 17, 2014 11:01 PM
Points: 6, Visits: 180

Thanks EdVassie, but that does not really address the issue.  I don't have a problem with internal SQL security on objects.

The issue is the delegated permission from Active Directory.  I want to know the DOMAIN\SecurityGroup with which the DOMAIN\User has gained access to the database.  As a work around I have a mapping table in my database that maps Active Directory users to their groups.  This can be handled by .NET in the front end, but I won't even mention the legacy platform I'm working with here.

If I know the  DOMAIN\SecurityGroup, which I have used for login and object permissions, then I can query sp_helprotect and determine what permissions the current user has on the object, and hence what controls to enable.  Otherwise I would have to wait for a fail on commit, which would be annoying for the user as they would not know until the end of a process whether it will succeed. 

 

 

Post #368850
Posted Friday, May 25, 2007 2:41 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, August 27, 2014 7:04 AM
Points: 278, Visits: 304

2 issues

1st....can a user belong to more than 1 AD security group...(for different reasons).  Technically I think the answer would be yes....so I think you need to cater for looping through multiple results.

2nd....you should be looking to build an AD lookup/interface routine to execute this functionaility...I've seen others point to resources for doing such actions....search for "AD, SQL, Lookup/interface" and see if anything useful comes up.  I don't think it's a native SQL "system variable".




Post #368936
Posted Wednesday, February 4, 2009 12:19 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, April 2, 2014 1:20 PM
Points: 16, Visits: 144
i've a similar requirement. My server has a really messy security system. there are different domains with different trust level and users are granted access to the SQL server by 1) directly granting access to their domain ids or 2)sometimes through group membership or 3) domain local groups or 4) local groups etc.
So when ever we have a server migration, there will be some people who complain they had access onthe old server but doesn't have access on the new server. So finally it would come up to determine, how they had permission on the first place.
So is there an option anywhere in sQL to determine, what are the access levels through which the user have access right now.
Post #650222
Posted Wednesday, February 4, 2009 2:02 PM


Keeper of the Duck

Keeper of the Duck

Group: Moderators
Last Login: 2 days ago @ 7:50 AM
Points: 6,624, Visits: 1,874
Yes, a Windows account can be a member of multiple security groups. Yes, Windows security groups can nest within Active Directory. To be honest, as a former directory services administrator, your directory services administrators should be able to provide these mappings to you. There's nothing native within SQL Server that gets it all. Your DS admins should have the tools which do.


K. Brian Kelley, CISA, MCSE, Security+, MVP - SQL Server
Regular Columnist (Security), SQLServerCentral.com
Author of Introduction to SQL Server: Basic Skills for Any SQL Server User
| Professional Development blog | Technical Blog | LinkedIn | Twitter
Post #650364
Posted Tuesday, July 13, 2010 6:19 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, August 25, 2014 1:44 PM
Points: 70, Visits: 428
Good question, I was also looking for a query to tell me quickly which grp does a domain\user belongs to, the closest I think is(not a complete answer), xp_logininfo

EXEC XP_LOGININFO 'domain\groupname','members'
EXEC XP_LOGININFO 'domain\groupname','all'

-- let me know if there is another easier way.
Post #951922
Posted Monday, January 30, 2012 12:27 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 9:43 AM
Points: 98, Visits: 264
SQL Secure does a fine job of determining inherited permissions.

Jeff Bennett
Saint Louis



Post #1243848
Posted Monday, January 30, 2012 12:28 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 9:43 AM
Points: 98, Visits: 264
SQL Secure does a fine job of determining inherited permissions.

Jeff Bennett
Saint Louis



Post #1243854
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse