Guest User

Untitled

a guest
Aug 15th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. Is there a way to register user and password for an account on IIS?
  2. using ( new Impersonator( "myUsername", "myDomainname", "myPassword" ) )
  3. {
  4. // <code that executes under the new context>
  5. }
  6.  
  7. //Initialize the metabase path
  8. string metabasePath = "IIS://localhost/W3SVC/AppPools";
  9. //Specify the name for your application pool
  10. string appPoolName = "testAppPool"; //specify the domain account as domainusername
  11. //Specify the identity that will run the application pool
  12. string appPoolUser = "User1";
  13. //Specify the password for the user
  14. string appPoolPass = "Password1";
  15. DirectoryEntry pool1;
  16. DirectoryEntry apppools = new DirectoryEntry(metabasePath);
  17. pool1 = apppools.Children.Find(appPoolName, "IIsApplicationPool");
  18.  
  19. /*Change Application Pool Identity*/
  20. pool1.InvokeSet("AppPoolIdentityType", new Object[] { 3 });
  21. pool1.InvokeSet("WAMUserName", new Object[] { Environment.MachineName + @"" + appPoolUser }); //If you are using a local account
  22.  
  23. pool1.InvokeSet("WAMUserPass", new Object[] { appPoolPass });
  24. /*Commit changes*/
  25.  
  26. pool1.CommitChanges();
Add Comment
Please, Sign In to add comment