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 72733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:05:27+00:00 2026-05-10T20:05:27+00:00

We have an application that installs SQL Server Express from the command line and

  • 0

We have an application that installs SQL Server Express from the command line and specifies the service account as the LocalSystem account via the parameter SQLACCOUNT=’NT AUTHORITY\SYSTEM’.

This doesn’t work with different languages because the account name for LocalSystem is different. There’s a table listing the differences here:

http://forums.microsoft.com/MSR/ShowPost.aspx?PostID=685354&SiteID=37

This doesn’t seem to be complete (the Swedish version isn’t listed). So I’d like to be able to determine the name programmatically, perhaps using the SID?

I’ve found some VB Script to do this:

Set objWMI = GetObject('winmgmts:root\cimv2')   Set objSid = objWMI.Get('Win32_SID.SID='S-1-5-18'')   MsgBox objSid.ReferencedDomainName & '\' & objSid.AccountName  

Does anyone know the equivalent code that can be used in C#?

  • 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. 2026-05-10T20:05:28+00:00Added an answer on May 10, 2026 at 8:05 pm

    You can use .NET’s built-in System.Security.Principal.SecurityIdentifier class for this purpose: by translating it into an instance of NtAccount you can obtain the account name:

    using System.Security.Principal;   SecurityIdentifier sid = new SecurityIdentifier('S-1-5-18'); NTAccount acct = (NTAccount)sid.Translate(typeof(NTAccount)); Console.WriteLine(acct.Value); 

    Later edit, in response to question in comments: you do not need any special privileges to do SID-to-name lookups on the local machine — for example, even if the user account you’re running under is only in the Guests group, this code should work. Things are a little bit different if the SID resolves to a domain account, but even that should work correctly in most cases, as long as you’re logged on to the domain (and a domain controller is available at the time of the lookup).

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

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The distinction between quad.scale= 10 and quad.scale= MySin() Is minor.… May 11, 2026 at 11:45 pm
  • Editorial Team
    Editorial Team added an answer The "regex magic" you need is just sub (which does… May 11, 2026 at 11:45 pm
  • Editorial Team
    Editorial Team added an answer I don't know your DB-Wrapper you use, but I want… May 11, 2026 at 11:45 pm

Related Questions

Good morning, all. This is my first question on stackoverflow, so hopefully this isn't
I have a legacy VB6 application that was built using MSDE. As many client's
I have inherited a VB6/Access application that we have developed and sold for many
I have an ASP .NET application that connects to an Oracle or a SQL

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.