Search code examples
.netwindowssecurity.net-4.0principalpermission

Why is System.Environment.MachineName value uppercased?


My machine name is lowercased (i see that in Advanced system settings dialog, Computer Name tab) but System.Environment.MachineName reports it uppercased. Why is that? This is a real problem for me because from my tests PrincipalPermissionAttribute performs case sensitive comparison for role names (i map my custom roles to Windows groups and my environment is non-domain). Any advise?


Solution

  • Use Dns.GetHostName instead, that should return it with the correct case (at least it does on my computer).