Microsoft KB Archive/894092

= FIX: Your application cannot load resources from a satellite assembly if the impersonated user account does not have permissions to access the application .config file in the .NET Framework 1.1 Service Pack 1 =

Article ID: 894092

Article Last Modified on 12/3/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.1 Service Pack 1
 * Microsoft Office SharePoint Portal Server 2003

-





SYMPTOMS
When you use impersonation in your Microsoft .NET Framework 1.1 Service Pack 1 (SP1) based application and the impersonated user account does not have permissions to access the application .config file, the application cannot load resources from satellite assemblies.

When this problem occurs, neutral resources are returned instead of the resources that are contained in the satellite assembly.

Also, in non-English versions of Microsoft Office SharePoint Portal Server 2003, the Site Settings page is displayed in English.

Note This behavior might occur in other non-English versions of SharePoint Portal Server 2003 that have not yet been reported.



RESOLUTION
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next .NET Framework 1.1 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

Prerequisites
The .NET Framework 1.1 Service Pack 1 is required.

Restart requirement
You must restart your computer after you apply this hotfix.

Hotfix replacement information
This hotfix does not replace any other hotfixes.

File information
The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.    Date         Time   Version            Size    File name --  06-May-2005  07:37  1.1.4322.2323   2,138,112  Mscorlib.dll 06-May-2005 07:39                     10,904  Mscorlib.ldo 06-May-2005 07:48  1.1.4322.2323   2,519,040  Mscorsvr.dll 06-May-2005 07:49  1.1.4322.2323   2,506,752  Mscorwks.dll



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the problem
 Create satellite assembly. To do this, follow these steps:   Create a text file that is named MyRes.txt, and then add the following text to the file: TEST1 = &quot;TEST1 for Neutral resource&quot;  Create a resource file that is named MyRes.resources by running the following command:

resgen MyRes.txt MyRes.resources

 Create a resource assembly that is named MyRes.dll by running the following command:

al /t:lib /embed:MyRes.resources /culture:neutral /out:MyRes.dll

 Create a folder in your project that is named ja-jp to store another culture.</li>  Create a text file that is named MyRes.txt in the new folder, and then add the following text to the file: TEST1 = &quot;TEST1 for Japanese&quot; </li> Create a resource file that is named MyRes.ja-jp.resources in the new folder by running the following command:

resgen MyRes.txt MyRes.ja-jp.resources

</li> Create a resource assembly that is named MyRes.resource.dll by running the following command:

al /t:lib /embed:MyRes.ja-jp.resources /culture:ja-jp /out:MyRes.resources.dll

</li></ol> </li> Create a console application. To do this, follow these steps: <ol style="list-style-type: lower-alpha;">  Create a Microsoft Visual C# source file that is named Test.cs, and then add the following code example to the file. // Test.cs // using System; using System.Runtime.InteropServices; using System.Security.Principal; using System.Security.Permissions;

class Class1 {   [DllImport(&quot;advapi32.dll&quot;, SetLastError=true)] public static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);

[DllImport(&quot;kernel32.dll&quot;, CharSet=CharSet.Auto)] public extern static bool CloseHandle(IntPtr handle);

[DllImport(&quot;advapi32.dll&quot;, CharSet=CharSet.Auto, SetLastError=true)] public extern static bool DuplicateToken(IntPtr ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle);

static void Main(string[] args) {       string str;

// Load MyRes.dll and initialize ResouceManager. System.Reflection.Assembly asm = System.Reflection.Assembly.Load(&quot;MyRes&quot;); System.Resources.ResourceManager res = new System.Resources.ResourceManager(&quot;MyRes&quot;, asm);

// Perform impersonation. IntPtr tokenHandle = new IntPtr(0); IntPtr dupeTokenHandle = new IntPtr(0); string UserName, Password; UserName = &quot;testuser&quot;; // Change the user name and password correctly. Password = &quot;testuser&quot;; // Change the user name and password correctly. const int LOGON32_PROVIDER_DEFAULT = 0; const int LOGON32_LOGON_INTERACTIVE = 2; const int SecurityImpersonation = 2;

tokenHandle = IntPtr.Zero; dupeTokenHandle = IntPtr.Zero;

bool returnValue = LogonUser(UserName, &quot;.&quot;, Password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,ref tokenHandle); bool retVal = DuplicateToken(tokenHandle, SecurityImpersonation, ref dupeTokenHandle); WindowsIdentity newId = new WindowsIdentity(dupeTokenHandle); WindowsImpersonationContext impersonatedUser = newId.Impersonate;

// Try to obtain the &quot;ja-jp&quot; string from the satellite assembly. str = res.GetString(&quot;TEST1&quot;, new System.Globalization.CultureInfo(&quot;ja-jp&quot;));

// Determine the result of the ResouceManager.GetString method. Console.WriteLine(str);

// Determine the current user name. str = System.Security.Principal.WindowsIdentity.GetCurrent.Name; Console.WriteLine(str);

impersonatedUser.Undo;

if (tokenHandle != IntPtr.Zero) CloseHandle(tokenHandle); if (dupeTokenHandle != IntPtr.Zero) CloseHandle(dupeTokenHandle); } } </li> Create the Test.exe application. To do this, compile Test.cs by using the following command:

csc test.cs

</li> Create a empty Test.exe.config file in the same folder as the Test.exe application.</li> Make sure that MyRes.dll is in the same folder as the Test.exe application.</li> In the same folder as the Test.exe application, create a subfolder that is named ja-jp.</li> Copy the MyRes.resource.dll file to the ja-jp subfolder.</li></ol> </li> Create a new user account. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> Create a new user account that is named testuser, and then set the password to testuser.</li> Add the testuser user account to the Local Administrator Group.</li> Change the file permission on the Test.exe.config file to Deny all for the testuser user account.</li></ol> </li> At a command prompt, run the Test.exe application.

When you run the application, TEST1 for Neutral resource is returned instead of TEST1 for Japanese.</li></ol>

For more information, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

Keywords: kbbug kbfix kbqfe kbresource kbprb kbnetframe110presp2fix kbhotfixserver kbwinserv2003sp2fix KB894092

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.