Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to determine SQL Security Login group for windows login when user is member of active directory...


How to determine SQL Security Login group for windows login when user is member of active directory security group.

Author
Message
Jamie Johnson-406551
Jamie Johnson-406551
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 185

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.

 

 

 

 


EdVassie
EdVassie
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3144 Visits: 3815
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 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005. 1 Dec 2016: now over 39,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Quote: "When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist." - Archbishop Hélder Câmara
Jamie Johnson-406551
Jamie Johnson-406551
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 185

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. 

 

 


AndrewMurphy
AndrewMurphy
SSC Veteran
SSC Veteran (280 reputation)SSC Veteran (280 reputation)SSC Veteran (280 reputation)SSC Veteran (280 reputation)SSC Veteran (280 reputation)SSC Veteran (280 reputation)SSC Veteran (280 reputation)SSC Veteran (280 reputation)

Group: General Forum Members
Points: 280 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".





smk-127973
smk-127973
Grasshopper
Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)

Group: General Forum Members
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.
K. Brian Kelley
K. Brian Kelley
Keeper of the Duck
Keeper of the Duck (6.8K reputation)

Group: Moderators
Points: 6770 Visits: 1908
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
SQLRocker
SQLRocker
Valued Member
Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)

Group: General Forum Members
Points: 70 Visits: 490
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.
chudman
chudman
SSC-Enthusiastic
SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)

Group: General Forum Members
Points: 149 Visits: 394
SQL Secure does a fine job of determining inherited permissions.

Jeff Bennett
Saint Louis



chudman
chudman
SSC-Enthusiastic
SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)

Group: General Forum Members
Points: 149 Visits: 394
SQL Secure does a fine job of determining inherited permissions.

Jeff Bennett
Saint Louis



Enmanuel Sanchez-420531
Enmanuel Sanchez-420531
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 136
The xp_logininfo reports the Domain groups (or other valid SQL login) how the user is being granted access.

https://msdn.microsoft.com/en-us/library/ms190369.aspx
EXEC xp_logininfo 'BUILTIN\Administrators';

EXEC xp_logininfo 'Contoso\JSmith'

Result:
account name   type   privilege   mapped login name   permission path
Contoso\JSmith   user   admin    Contoso\JSmith    Contoso\DBAdmins
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search