0

I want to get the username of the user using the application. So i want to use WindowsIdentity.GetCurrentUser() . Refer How do I get the current username in .NET using C#?

But the problem is the System.Security.Principal namespace does not give me any such class. In fact the namespace shows only the two interface and no classes. http://msdn.microsoft.com/en-us/library/System.Security.Principal(v=vs.110).aspx

I tried it on a server machine and on a local machine. Doesnt work.

Since that did not work i tried Environment.username. But Visual Studia cant find the property either. I opened the metadata file but no such property exists.http://msdn.microsoft.com/en-us/library/System.Environment(v=vs.100).aspx.

What am i doing wrong? FYI i'm working on a .net 4 silverlight application.

AfterThought: Is this because of silverlight?

Community
  • 1
  • 1
amaturcoder
  • 25
  • 1
  • 7
  • I look at http://msdn.microsoft.com/en-us/library/System.Security.Principal(v=vs.110).aspx page and I see WindowsIdentity class in the package – Dmitriy Finozhenok Mar 13 '14 at 06:31
  • @DmitriyFinozhenok Switch that page to Silverlight instead of .NET 4.5 and you will see. – nvoigt Mar 13 '14 at 06:35
  • possible duplicate of [Silverlight 4 Get Current User](http://stackoverflow.com/questions/3470926/silverlight-4-get-current-user) – nvoigt Mar 13 '14 at 06:38
  • @nvoigt, its a web application so cant be WPF. I think the link u have given will work. Let me try that. Thanks. – amaturcoder Mar 13 '14 at 06:49

1 Answers1

0

Silverlight is a browser based framework. Reading the current operating system user is not possible. If you need to communicate with the users Desktop that way, write a normal WPF application for Windows Desktop.

nvoigt
  • 75,013
  • 26
  • 93
  • 142