What account is my ASP.NET code running as/under?

You can find this out by using the following code (1 line):

System.Security.Principal.WindowsIdentity.GetCurrent.User.Translate(GetType(System.Security.Principal.NTAccount)).Value

Advertisements

Fixing Hyper V “VMName failed to change state” error 32788

If you find yourself getting this error message:

The application encountered an error while attempting to change the state of ‘VMName’.  ‘VMName’ failed to change state.  The operation failed with error code ‘32788.’

image

Go to the settings of your VM:

image

And look for something in an error state:

image

In this case I had changed Virtual Switch since using the VM so it’s no longer valid.

Remoting (RDP) to Azure service: This User Has Expired

If you are trying to RDP into an Azure service and you get the message “This User Has Expired” that’s because when Cloud Services are deployed, the user is only enabled for a short period of time.  If you don’t want to fully redeploy your application you can modify the expiration.

To do this, go to the service’s Configuration section and click the Download button to download the configuration file.

image

In that configuration file you’ll need to change the value for:

Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration

image

Go back to the configuration page and upload this file using the Upload button.  Press Save and after a few moments it will change your user accounts expiration date.