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

A typical code fragment obtained from the YouTube embed feature looks like this: <object
This has been driving me crazy for 2 days. I have been trying to
I have a query in SQL Server that I am trying to convert to
I had a discussion recently about looking for a method to generate truly random
So I have 2 SQL servers, both internal on the firewall, and my webserver
I'm calculating the Euclidean distance between n-dimensional points using OpenCL. I get two lists
I am trying to write a predicate to transform an array of elements into
Is there a way to set the context for your DataService in WCF Data
I have been looking at using Linq to entities with WCF for some projects
I'm using RMI to allow access to my Java application via MATLAB, which runs

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.