2012-02-18 5 views
2

ServiceDefinition.csdef 또는 다른 곳에서 IIS로 이동하여 직접 조정하지 않고도이 작업을 수행 할 수 있습니까?Azure에서 LocalSystem으로 응용 프로그램 풀의 ID 설정

나는 webrole에 대해 executionContext="elevated"을 시도했지만 작동하지 않았습니다.

UPDATE

설치하면 푸른 IIS에, 내가 간 것이다 아래의 오류 "6 메타베이스 호환성 IIS".

이렇게하면 Azure의 배포 단계에서 "IIS 6 메타베이스 호환성"이 자동으로 설치됩니다.


@astaykov, 내가 댓글을 남기고하지만 너무 큰 아래의 코드는, 그래서이 곳을 사용합니다.

나는대로 웨이드 바그너가 쓴 같은 코드를 사용합니다 appPoolName에서

public override bool OnStart() 
     { 
      // http://code.msdn.microsoft.com/windowsazure/CSAzureChangeAppPoolIdentit-27099828 
      // This variable is used to iterate through list of Application pools 
      string metabasePath = "IIS://localhost/W3SVC/AppPools"; 
      string appPoolName; 
      using (ServerManager serverManager = new ServerManager()) 
      { 
       //Get the name of the appPool that is created by Azure 
       appPoolName = serverManager.Sites[RoleEnvironment.CurrentRoleInstance.Id + "_Web"].Applications.First().ApplicationPoolName; 
       // Get list of appPools at specified metabasePath location 
       using (DirectoryEntry appPools = new DirectoryEntry(metabasePath)) 
       { 
        // From the list of appPools, Search and get the appPool that is created by Azure 
        using (DirectoryEntry azureAppPool = appPools.Children.Find(appPoolName, "IIsApplicationPool")) 
        { 
         if (azureAppPool != null) 
         { 
          // Refer to: 
          // http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e3a60d16-1f4d-44a4-9866-5aded450956f.mspx?mfr=true, 
          // http://learn.iis.net/page.aspx/624/application-pool-identities/ 
          // for more info on AppPoolIdentityType 
          azureAppPool.InvokeSet("AppPoolIdentityType", new Object[] { 0 }); // MD_APPPOOL_IDENTITY_TYPE_LOCALSYSTEM 
          // Write above settings to IIS metabase 
          azureAppPool.Invoke("SetInfo", null); 
          // Commit the above configuration changes that are written to metabase 
          azureAppPool.CommitChanges(); 
         } 
        } 
       } 
      } 
      RoleInRun = true; 
      TaskInRun = false; 
      return base.OnStart(); 
     } 

내가 얻을 수 rigth 값을, 그러나 오류가 여기 있었 : using (DirectoryEntry azureAppPool = appPools.Children.Find(appPoolName, "IIsApplicationPool"))

내가 사방하지만 여전히 해결책을 찾고 있어요 단서를 찾을 수 없습니다 IIS 이벤트의 오류 :

Application: WaIISHost.exe 
Framework Version: v4.0.30319 
Description: The process was terminated due to an unhandled exception. 
Exception Info: System.Runtime.InteropServices.COMException 
Stack: 
    at System.DirectoryServices.DirectoryEntry.Bind(Boolean) 
    at System.DirectoryServices.DirectoryEntry.Bind() 
    at System.DirectoryServices.DirectoryEntry.get_IsContainer() 
    at System.DirectoryServices.DirectoryEntries.Find(System.String, System.String) 
    at GimmeRank.Redirector.WebRole.OnStart() 
    at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleType) 
    at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<InitializeRole>b__0() 
    at System.Threading.ExecutionContext.runTryCode(System.Object) 
    at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object) 
    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 
    at System.Threading.ThreadHelper.ThreadStart() 

Anyideas?

답변

3

executionContext = "elevated"는 RoleEntryPoint를 로컬 SYSTEM 계정으로 만 실행하지만 IIS 풀 ID는 아닙니다.

this blog post by Wade Wagner을 확인하시기 바랍니다. 그곳에서 설명하는 내용은 executionContext = "elevated"와 함께 OnStart 메소드에서 실행할 수 있습니다 (관리자 만 풀 ID를 변경할 수 있기 때문에). 로컬 시스템에서 작동하지 않는 경우 RDP 사용자를 만들면 Administrators 그룹에 추가되고 해당 사용자에게 iis 응용 프로그램 풀 ID를 설정할 수 있습니다.

UPDATE

흠, 나는 다음과 같은 방법을 사용 (유사하다) 그리고 그것은 잘 작동 :

private void SetAppPoolIdentity() 
{ 
    string appPoolUser = "myRDP_admin_user"; 
    string appPoolPass = "my_super_secure_password"; 

    Action<string> iis7fix = (appPoolName) => 
    { 
     bool committed = false; 
     while (!committed) 
     { 
      try 
      { 
       using (ServerManager sm = new ServerManager()) 
       { 
        var applicationPool = sm.ApplicationPools[appPoolName]; 
        applicationPool.ProcessModel.IdentityType = ProcessModelIdentityType.SpecificUser; 
        applicationPool.ProcessModel.UserName = appPoolUser; 
        applicationPool.ProcessModel.Password = appPoolPass; 
        sm.CommitChanges(); 
        committed = true; 
       } 
      } 
      catch (FileLoadException fle) 
      { 
       Trace.TraceError("Trying again because: " + fle.Message); 
      } 
     } 
    }; 

    // ServerManager in %WinDir%System32InetSrvMicrosoft.Web.Administration.dll 
    var sitename = RoleEnvironment.CurrentRoleInstance.Id + "_Web"; 
    var appPoolNames = new ServerManager().Sites[sitename].Applications.Select(app => app.ApplicationPoolName).ToList(); 
    appPoolNames.ForEach(iis7fix); 
} 

당신은 그것을 시도 할 수 있을까요? 실제 계정이 아니기 때문에 로컬 시스템 계정에서는 작동하지 않으며 최소한이 방법으로 설정할 수는 없습니다 (최소한 어떻게해야할지 모르지만 RDP에 대한 특정 계정은 정상적으로 작동합니다).

0

만들기 start.cmd :

FOR /F "tokens=*" %%A IN ('%windir%/system32/inetsrv/APPCMD list wp /text:apppool.name') DO (

%systemroot%/system32/inetsrv/APPCMD set config /section:applicationPools /[name='%%A%':'].processModel.identityType:LocalSystem 

) 
관련 문제