Re: Get list of the Groups a User belongs to

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

On a Windows Server 2003 domain you can construct a WindowsIdentity by
passing in the user's name in the form, name@domain:

"WindowsIdentity(String) Constructor"
http://msdn2.microsoft.com/en-us/library/td3046fc.aspx

Then you can access the Groups property (2.0 framework only):

"WindowsIdentity.Groups Property"
http://msdn2.microsoft.com/en-us/library/system.security.principal.windowsidentity.groups.aspx

If you can't use the above solution since you are using a different version
of the framework or a different domain then I think you'll have to resort to
the unmanaged APIs such as LogonUser:

"LogonUser"
http://msdn2.microsoft.com/en-us/library/aa378184.aspx

The above will get you the User's token, which you can pass to the following
function:

"GetTokenInformation"
http://msdn2.microsoft.com/en-us/library/aa446671.aspx

Specify the value of TOKEN_GROUPS for the TokenInformationClass argument.

(Note that I haven't used these APIs myself)

You'll have to use P/Invoke for this, of course :)

--
Dave Sexton

"Jeff Williams" <jeff.williams@xxxxxxxxxxxxxxx> wrote in message
news:12nl6l665t0o610@xxxxxxxxxxxxxxxxxxxxx
How can I get a list of the Groups both Local and Domain groups a User
belongs to.


.



Relevant Pages

  • interop.word.dll -- documents.add() does not return a Word.document type
    ... I have a VB.NET web application (1.1 framework) that creates a new Word ... I have a Windows Server 2003 with ... Event Logs and could not find any error messages! ...
    (microsoft.public.dotnet.framework.interop)
  • Creating a new Word document through VB.NET
    ... I have a VB.NET web application (1.1 framework) that creates a new Word ... I have a Windows Server 2003 with ... Event Logs and could not find any error messages! ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP.NET
    ... Windows server) supports FP extensions, it does not support the password ... It will install ASP.NET processing and create the ASPNET user ... The 2.0 Framework requires VS.NET 2005 or a 2005 ... Using the code in a kind of Scripting way inside the HTML ...
    (microsoft.public.dotnet.general)
  • Migrate from vs2005 to vs2008
    ... winforms application in Windows XP and WCF ... Windows XP and windows server 2003 have Framework 3.0 ... Iwant migrate to Framework 3.5 and vs 2008 team system. ... Any problem migrating ?? ...
    (microsoft.public.dotnet.languages.csharp)
  • isInRole
    ... user name and then check the user membership in some local group ... I read in one of the previous threads that this was a bug in Framework ... :Windows Server 2003,.net Framework v1.1,Windows SharePoint Services ...
    (microsoft.public.dotnet.framework.aspnet.security)