Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query Active Directory

Author  Topic 

darrenkelly
Starting Member

2 Posts

Posted - 2003-06-11 : 05:45:53
Hi,

I am trying to use SQL Server to Query an Active Directory Server.

I have successfully setup the Directory Server as a link Server and successfully queried the Server to give me a list of Users and Groups.

However what I am trying to do now is get a list of Users and the Groups they are in but to no avail.

If anyone can provide an example or give me advice on how to do this, it would be greatly apprecited.

Thanking you in advance

Darren

X002548
Not Just a Number

15586 Posts

Posted - 2003-06-11 : 09:21:14
I'm sorry...my ignorance is showing (again)...

What's Active Directoy Server?



Brett

8-)
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2003-06-11 : 22:50:57
quote:
What's Active Directoy Server?


I think he meant the active directory or maybe the AD global catalog. I have don this in c#, but never through QA.

-Chad

http://www.clrsoft.com

Software built for the Common Language Runtime.
Go to Top of Page

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2003-06-12 : 02:54:29
If you just want members of groups that have have logins on SQL Server you can use
exec master..xp_logininfo 'domain\groupname','members' 
otherwise you can use the following code to create a system stored procedure
USE Master
GO

EXEC sp_configure 'allow updates', 1
RECONFIGURE WITH OVERRIDE
GO

EXEC sp_ms_upd_sysobj_category 1
GO

CHECKPOINT
GO

CREATE PROC xp_GetNTGroupMembers
@acctname sysname --IN: NT group name
AS
SELECT Name
FROM OPENROWSET(NetGroupGetMembers, @acctname) AS NT
GO

EXEC sp_ms_upd_sysobj_category 2
GO

EXEC sp_configure 'allow updates', 0
RECONFIGURE WITH OVERRIDE
GO




HTH
Jasper Smith

0x73656c6563742027546f6f206d7563682074696d65206f6e20796f75722068616e6473203f27
Go to Top of Page

Andraax
Aged Yak Warrior

790 Posts

Posted - 2003-06-12 : 05:20:36
Jasper: That's great! You learn something new every day being around you guys :)

Go to Top of Page
   

- Advertisement -