0

I want to get the CultureInfo used by another user (that is not logged on). I thought I could use impersonation as described in this question, but CultureInfo seems to ignore the impersonation.

If I do WindowsIdentity.GetCurrent().Name) I get the name of the non-logged-on user, but if I do CultureInfo.CurrentCulture I get the culture of the user starting the application instead!

How can I get the CultureInfo for another user?

I previously looked at GetUserDefaultLocaleName in the Windows APIs, but I'm not familiar enough with InterOp so I could never get it working, and I couldn't find any online examples on how to use it from C#. So I don't know if that method will actually work or if it will experience the same issue.

Community
  • 1
  • 1
TheHvidsten
  • 4,028
  • 3
  • 29
  • 62
  • I'll say that it is cached. Try resetting `CultureInfo.s_userDefaultCulture;` and `CultureInfo.s_userDefaultUICulture` (they are `private static` fields of `CultureInfo`, use reflection) and see what happens. I can't do the test because I don't have code to do user impersonation, nor I have users with different locales. If it works, **it isn't a solution! it is only a test** – xanatos Mar 28 '17 at 14:15
  • 1
    the reason you are getting this problem is because you are impersonating the users identity alone, the program automatically uses your local computers culture...the easiest possible solution would be to write the users culture to a table when the user logs in....at least in my oppinion – Bernard Walters Mar 28 '17 at 14:30

0 Answers0