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


Active Directory Groups


Active Directory Groups

Author
Message
ron.grace
ron.grace
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 55
Excuse my ignorance, but I'm fairly new to SQL and Visual Studio. I'm creating a VB app that allows users to access archive data relating to a number of different companies. I only want allow them to view certain company's data. I was told about active directory and have now had some AD groups created and added various users to these groups.
On the initial screen within the app is a 'Company Select' screen. What I want to do is enable/disable buttons depending on what AD group the user is in, what data item can I use which relates to the AD group. e.g.

If user is a member of AD group 1 then company1button.enable = True
Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14958 Visits: 38965
ron there's a built in extended procedure that can tell you what Ad groups an AD login belongs to.

the problem is, you do NOT want to grant everyone access to extended stored procs.

the syntax is simple:

EXEC master..xp_logininfo @acctname = 'mydomain\lowell',@option = 'all' -- Show all paths a user gets his auth from
go

EXEC master..xp_logininfo @acctname = 'mydomain\authenticatedusers',@option = 'members' -- show group members




since in reality, people change/get added/drop from groups very rarely, i would suggest scanning a list of users and put all their groups into a single static table;

then use that table for your test, and update it once a week or so.

here's a very basic example;

CREATE TABLE [dbo].[#TMP] (
[ACCOUNT NAME] NVARCHAR(256) NULL ,
[TYPE] VARCHAR(8) NULL ,
[PRIVILEGE] VARCHAR(8) NULL ,
[MAPPED LOGIN NAME] NVARCHAR(256) NULL ,
[PERMISSION PATH] NVARCHAR(256) NULL )

INSERT INTO #tmp
EXEC master..xp_logininfo @acctname = 'mydomain\lowell',@option = 'all'

IF EXISTS(SELECT 1 FROM [dbo].[#TMP] WHERE [account name] = ORIGINAL_LOGIN() AND [permission path] = 'BUILTIN\Administrators')
PRINT 'whoopee!'

--all inline as a single command:
IF EXISTS(SELECT 1 FROM (SELECT *
FROM OPENROWSET('SQLOLEDB','Server=DEV223\SQL2005;Trusted_Connection=Yes;Database=Master',
'Set FmtOnly OFF; EXEC master..xp_logininfo @acctname = 'mydomain\lowell'',@option = ''all'' '
)
) MyAlias
WHERE [account name] = ORIGINAL_LOGIN()
AND [permission path] = 'BUILTIN\Administrators')
PRINT 'whoopee!'



Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

ron.grace
ron.grace
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 55
Many thanks for your response, I'll give it a go and let you know how I get on
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