Creating an Encrypted IIS Application Pool Identification Password Using IISWASOnlyAesProvider

I would like to create an encrypted password using the algorithm used in IIS.

The encrypted value looks like this (in applicationHost.config):

<applicationPools> 
    <add name="MyAppPool"> 
        <processModel identityType="SpecificUser" userName="TestUser" 
password="[enc:IISWASOnlyAesProvider:N8mr4dLU6PnMW5xlmCWg6914cKePgeU0fTbxew 
ZppiwyTLmBQh0mZnFywQO78pQY:enc]" /> 
    </add> 
</applicationPools>

Link: http://technet.microsoft.com/en-us/library/dd163536.aspx

I see that the car keys are stored here:

C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys

Link: http://www.asprangers.com/post/2012/05/03/MachineKeys-on-IIS-7x-Inside-Out.aspx

I would like to write some C # to do this, but I am not a cryptography expert ... Can I use something like code in the accepted SO answer below, using an open text password and a key from machine keys to generate an encrypted password as shown above?

Using AES Encryption in C #

+4
1

, IIS, IIS? , API , Microsoft.Web.Administration.ServerManager, :

    using(ServerManager serverManager = new ServerManager()) { 
        Configuration config = serverManager.GetApplicationHostConfiguration();

        ConfigurationSection sitesSection = config.GetSection("system.applicationHost/sites");

        ConfigurationElement virtualDirectoryDefaultsElement = sitesSection.GetChildElement("virtualDirectoryDefaults");
        virtualDirectoryDefaultsElement["password"] = @"asd";

        serverManager.CommitChanges();
    }
0

All Articles