2

I'm using the following code to create an App Pool:

var appPool = serverManager.ApplicationPools.Add(Name);
appPool.ProcessModel.IdentityType = ProcessModelIdentityType.SpecificUser;
appPool.ProcessModel.UserName = UserName;
appPool.ProcessModel.Password = Password;
serverManager.CommitChanges();

But somehow something goes wrong with the password and I don't know what. When I look into applicationHost.config the xml generated looks like this:

<processModel 
  identityType="SpecificUser" 
  userName="domain1\user1" 
  password="[enc:IISWASOnlyAesProvider:6RqsTbCqVXXnr37jLOrOjg==:enc]" />

If I add the same user (domain1\user1) manually over the IIS Manager the xml looks like that:

<processModel 
  identityType="SpecificUser" 
  userName="domain1\user1"
  password="[enc:IISWASOnlyAesProvider:OCkfPehXB3p8ahXXtaoW3vLTpFY/EbW5IFo39h5iVE2azpJXXvkArbeeuwI5bvBG:enc]" />

It looks like the password gets encrypted in a different way when created via code, but I didn't find anything topic regarding that in the web.

What I'm doing wrong or what I need to do to make the code work?

gsharp
  • 27,557
  • 22
  • 88
  • 134
  • It seems like both passwords are encrypted by the same IISWASOnlyAesProvider, which uses AES encryption using an RSA encrypted session key (http://technet.microsoft.com/en-us/library/dd163536.aspx). If you're sure you provide identical passwords, the only possible explanation left is that different RSA keys are used for encryptions. Try to investigate in the direction of using the same key or change the default encryption provider. – jwaliszko Sep 23 '13 at 09:13

2 Answers2

2

i've tried to reproduce it and it worked all the time. Sorry for the following question, but it happended a couple of times to myself:

Are you absolutely sure you've specified the right password?

AcidJunkie
  • 1,878
  • 18
  • 21
0

you can create app pool with username and password like this

using (ServerManager serverManager = new ServerManager())
           {
              
                   ApplicationPool newPool = serverManager.ApplicationPools.Add("Poolnam1");
                   newPool.ManagedRuntimeVersion = "v4.0";
                   newPool.ProcessModel.IdentityType = ProcessModelIdentityType.SpecificUser;
                   newPool.ProcessModel.UserName = accountUserName;
                   newPool.ProcessModel.Password = accountPassword;
                   serverManager.CommitChanges();

           
           }
Shahid Islam
  • 559
  • 3
  • 7