Question

I'm making the example in: http://msdn.microsoft.com/es-es/library/system.security.principal.windowsidentity(v=vs.100).aspx, and it works for a Console Application very well. But I want something like it for my project in Silverlight 5, but I can't to adapt it. It tells me: WindowsIdentity is not found here. Can somebody help me? I just need know the UserName used for the user to login to windows.

Was it helpful?

Solution

Silverlight works in a more restricted manner than standard windows desktop application, such as console application you tried. Not only WindowsIdentity but also some other ways to get current user's UserName using .NET framework are not available in Silverlight, for example :

System.Net.CredentialCache.DefaultCredentials
Environment.UserName

Some alternatives suggested as answer to this SO question (see answers those aren't accepted), mostly by creating web service to get UserName, and Silverlight application simply call web service's method. This concise but complete blog post shows you how to create such web service (WCF).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top