In Silverlight 4 OOB you can use the AutomationFactory when the App is running with elevated permissions.
var username = "";
if (App.Current.HasElevatedPermissions)
using (dynamic shellObj = AutomationFactory.CreateObject("WScript.Network"))
userName = shellObj.UserName;
Note that you need to reference
- Microsoft.CSharp.dll and
- System.Core.dll
Read more on this topic on Justin Angels Blog
If you are deploying a Silverlight 4-application it has to run out of the browser as the sandbox inside the browser does not allow ElevatedPermissions. If you decide to use Silverlight 5 you can enable ElevatedPermissions with an administrative account for in-browser apps (msdn.microsoft.com/en-us/library/ee721083(v=vs.95).aspx).
Though you can of course run the app inside the intranet-page it has no elevated permissions as long as you (or the user) don't install and run it OOB. Thus the app will not be able to access the username.
It seems this restriction is partially gone with Silverlight 5 but I have not tested this, yet and cannot tell you if you could go the way described above.