PDA

Click to See Complete Forum and Search --> : How to find all the login names with in a NTUserGroup


saikrishnat
Dec 20th, 2002, 04:05 PM
Hello all,

How to find all the login names with in a NTUserGroup account...

i,e how to find all logins in a group....?

(either from .NET or from SQL server is fine..)

ThankX
SaiKrishna

Slow_Learner
Dec 20th, 2002, 04:35 PM
You're most likely going to have to go to the API to get usergroup member information; from what I've read of the docs for .NET, the Framework intentionally does not include features to interact with OS security. Here's some info to help you get started along what, in my experience, is a painful and rocky road if you're not up to speed on API calls:

ms-help://MS.VSCC/MS.MSDNVS/netdir/ad/example_code_for_enumerating_groups.htm

There is an example in VB (I think VB6, sorry) of how to enumerate groups and members of each group in a local security database. Doesn't show how to extract the same info from a domain controller or an ActiveDirectory but hopefully it will get you started.

edit: Actually now that I look at that example a little closer it doesn't seem to be using API calls at all, which is kind of counter to what I remember last time I did any security stuff. Let me find some more stuff.
... Aha no wonder, the "VB" examples are actually VBScript. Where the hell was that security tutorial for VB...
... dammit they really bury that crap deep don't they *dig* *dig* ...


AH HA!! Here is the list of the OS functions that will do things with groups and users and servers and whatnot, e.g. enumerate lists of groups:

ms-help://MS.VSCC/MS.MSDNVS/netmgmt/ntlmapi2_86lv.htm

Group functions specifically:

ms-help://MS.VSCC/MS.MSDNVS/netmgmt/ntlmapi_95o3.htm

You're interested in NetGroupGetUsers:

ms-help://MS.VSCC/MS.MSDNVS/netmgmt/ntlmapi2_6i9f.htm

Hope this helps get you started. Hate to sound doom-and-gloom about this but when I did a few pretty simple utilities using these functions I found it extremely painful.

Oh and here are a bunch of examples in VB 5 and 6:

http://www.mvps.org/vbnet/index.html?code/network/index.html