all groups > sql server programming > november 2003 >
You're in the

sql server programming

group:

Getting NT group membership from TSQL



Re: Getting NT group membership from TSQL Russell Fields
11/25/2003 4:44:11 PM
sql server programming: Jonas,

FWIW, changes to names on the domain take a few minutes to replicate around.
I am not a net admin, but I have run into this in the past. If you wait a
few minutes are your results correct? (Takes as much as 15 minutes on the
domain where I work.)

Russell Fields

[quoted text, click to view]

Getting NT group membership from TSQL Jonas
11/25/2003 10:20:04 PM
Hi!

I'm trying to get the NT group membership of a specified username from TSQL.
I'm using the following to query the OS:

SELECT *
FROM OPENROWSET(NetUserGetGroups, @NTUserName) AS NT

It works fine except the fact that it seems that the result is cached
somewhere, because if I run it once when a user is member of a certain group
it, and then remove the user from the group and rerun the statement, it
still reports the user as a group member. Even if I remove the group
altogether, it still lists the group.

Any tips on this?

Brgds

Jonas

Re: Getting NT group membership from TSQL Jonas
11/25/2003 10:52:23 PM
Thanks for your answer which sounds resonable, but the group I'm playing
around with is a local group on my own computer, which should be available
directly. If I run the NET LOCALGROUP, the changes are instantaneous.

I think the "caching" takes places somewhere in the SQL Server, but I'm not
sure.

Brgds

Jonas

[quoted text, click to view]

Re: Getting NT group membership from TSQL Jonas
11/26/2003 6:24:31 PM
Some more investigations has revealed that the time for a group membership
change to appear when using this function is between a couple of minutes up
to almost ten minutes.

/Jonas

[quoted text, click to view]

Re: Getting NT group membership from TSQL Russell Fields
11/27/2003 4:12:47 PM
Jonas,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql7/html/sql7security.asp
(from 1999 and for SQL Server 7) implies some caching, but is not very
specific. One comment is :

When a user connects to SQL Server 7.0, the server creates a Process Status
Structure (PSS) structure in memory, which is comprised of the user's SID,
group SIDs, and other security and state information.

FWIW,
Russell Fields

[quoted text, click to view]

AddThis Social Bookmark Button