Question

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?

Was it helpful?

Solution

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?

OTHER TIPS

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();

           
           }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top