Jason Bower's WebLog

.NET and Multilingual Operating Systems

I ran into an interesting bug at work this week when discovered the .NET Framework SDK QuickStarts failed to setup up properly on German versions of Windows 2003 Server. The application that we use to setup up the sample databases with SQL grants the network service account access so that ASP.NET application will work properly. It turns out that on German versions of Windows 2003 Server the Network Service account is called NT-AUTORITÄT\NETZWERKDIENST. We had our code hardcoded to use NT Authority\NETWORK SERVICE. After some investigation on the development team it turns out that .NET provides an ENUM of well known OS accounts that you can access via managed code.

System.Security.Principal.WellKnownSidType provides access to accounts like Network Service that can be renamed on localized operating systems.

Way that you want to programmatically specify the NETWORK SERVICE account is to use some code like this:

 

using System;
using System.Security.Principal;
namespace ConsoleApplication2
{

   class Program
   {

      static void Main(string[] args)
      {

         SecurityIdentifier si = new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null);
         Console.WriteLine(si.Translate(typeof(NTAccount)).ToString());
         Console.Read();

      }

   }

}

 

 

 

Published Friday, April 01, 2005 8:45 PM by jbower

Comments

 

Sorting It All Out said:

April 1, 2005 7:59 PM
 

Michael Kaplan said:

Awesome post, and pleasure to trackback.... <br> <br>Of course technically it is not a multilingual OS if it is localized (unless you consider all versions of Windows multilingual like I mention at <a target="_new" href="http://blogs.msdn.com/michkap/archive/2005/03/30/404007.aspx">http://blogs.msdn.com/michkap/archive/2005/03/30/404007.aspx</a>). It is just a different monolingual UI. :-) <br> <br>
April 1, 2005 9:08 PM
 

David Smith said:

That is very interesting, and I appreciate your insight.
April 2, 2005 1:46 AM
 

Martin Kulov said:

Jason, which version of .NET Framework are you referring to? I could not find System.Security.Principal.WellKnownSidType in April's MSDN Library.
April 2, 2005 4:58 AM
 

Movies » Jason Bower’s WebLog : .NET and Multilingual Operating Systems said:

January 1, 2008 4:15 PM
 

Jason Bower s WebLog NET and Multilingual Operating Systems | Wood TV Stand said:

June 2, 2009 6:03 PM
 

Jason Bower s WebLog NET and Multilingual Operating Systems | fix my credit said:

June 16, 2009 9:46 PM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker