Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 686963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:04:41+00:00 2026-05-14T02:04:41+00:00

This has to be obtained from a remote machine. The following query works not

  • 0

This has to be obtained from a remote machine. The following query works not for SIDs, but for group and account names.

"SELECT GroupComponent FROM Win32_GroupUser WHERE PartComponent = \"Win32_UserAccount.Domain='" + accountDomain + "',Name='" + accountName + "'\""

The Win32_Group objects it returns come in the forms of strings, and they only have domain and name (even though Win32_Group has a SID property).

I have this sinking feeling I’ll have to:

  1. Turn the SID into an account name by querying Win32_SID;
  2. Perform the query above;
  3. Turn each of the resulting group names into SIDs by querying Win32_Group.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:04:41+00:00Added an answer on May 14, 2026 at 2:04 am

    Can you use the System.DirectoryServices.AccountManagement namespace classes?

    using (var context = new PrincipalContext( ContextType.Domain ))
    {
        using (var user = UserPrincipal.FindByIdentity( context, accountName ))
        {
            var groups = user.GetAuthorizationGroups();
            ...iterate through groups and find SIDs for each one
        }
    }
    

    It should work with ContextType.Machine, though you’d need to specify the machine name and have appropriate privileges.

    using (var context = new PrincipalContext( ContextType.Machine,
                                               "MyComputer",
                                               userid,
                                               password ))
    {
       ...
    }
    

    There’s a nice MSDN article (longish, though) on using the new .NET 3.5 account management namespace.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This has to be a frequent question, but not on SO yet, so it
I know this has been asked in various ways, but I have not been
This has probably something to do with my transformations, but right now I can't
I have a list of recipes obtained from a database that looks like this:
I have a dataset obtained from MySQL that goes like this: Array ( [0]
A typical code fragment obtained from the YouTube embed feature looks like this: <object
this has baffled me for a couple of hours now. Why do i get
this has been an ongoing problem with me, ive been trying to make a
This has been a massive headache. We use Ning as a our platform for
This has been frustrating me for a while now. I started developing a site

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.