다음을 통해 공유


FTP 보안 <> 요소

개요

요소는 <security> FTP 사이트의 보안 옵션에 대한 부모 요소를 정의하고 계층적으로 표시되는 다음 자식 요소를 포함합니다.

  • <authentication> - 이 자식 요소는 FTP 사이트에 대한 다양한 인증 설정의 부모 요소이며 다음 자식 요소를 포함합니다.

    • <anonymousAuthentication> - 익명 액세스에 대한 설정을 지정합니다. 이 인증 형식을 사용하면 서버 또는 할 일기본 사용자 계정 없이 FTP 사이트에 액세스할 수 있으며 공용 FTP 사이트에 가장 자주 사용됩니다.
    • <basicAuthentication> - 기본 인증에 대한 설정을 지정합니다. 이 인증 형식은 사용자가 로그인하기 전에 서버에 유효한 사용자 계정이 필요하거나 기본 합니다.
    • <clientCertAuthentication> - Active Directory 클라이언트 인증서 인증을 사용할 수 있는지 여부를 지정합니다. 이 인증 형식은 클라이언트 인증서를 사용하여 FTP 클라이언트를 인증합니다.
    • <customAuthentication> - 사용자 지정 인증에 대한 설정을 지정합니다. 이 인증 형식은 사용자 지정 인증 공급자를 사용하여 사용자 이름 및 암호의 유효성을 검사합니다.
  • <commandFiltering> - FTP 명령 필터링에 대한 설정을 지정합니다. 이 컬렉션을 사용하면 FTP 서비스에 대한 특정 FTP 명령을 개별적으로 허용하거나 거부할 수 있습니다.

  • <customAuthorization> - 사용자 지정 권한 부여에 대한 설정을 지정합니다. 이 권한 부여 형식은 기본 제공 권한 부여 공급자 또는 사용자 지정 권한 부여 공급자를 사용하여 사용자 액세스의 유효성을 검사합니다.

  • <dataChannelSecurity> - FTP 데이터 채널 보안에 대한 설정을 지정합니다. 이 보안 기능은 세션의 데이터 및 제어 채널에 일치하는 클라이언트 주소가 있어야 합니다.

  • <ssl> - FTP 사이트에 대한 SSL(Secure Sockets Layer) 설정을 지정합니다.

  • <sslClientCertificates> - FTP 사이트에 대한 SSL(Secure Sockets Layer) 클라이언트 인증서 설정을 지정합니다.

호환성

버전 주의
IIS 10.0 <security> IIS 10.0에서 요소가 수정되지 않았습니다.
IIS 8.5 <security> IIS 8.5에서 요소가 수정되지 않았습니다.
IIS 8.0 <customAuthorization> 요소를 <security> IIS 8.0의 기능으로 추가했습니다.
IIS 7.5 <security> 요소의 <ftpServer> 요소는 IIS 7.5의 기능으로 제공됩니다.
IIS 7.0 <security> 요소의 <ftpServer> 요소는 IIS 7.0에 대한 별도의 다운로드인 FTP 7.0에서 도입되었습니다.
IIS 6.0 <ftpServer> 요소와 해당 자식 요소는 LM/MSFTPSVC 메타베이스 경로에 있던 IIS 6.0 FTP 설정을 대체합니다.

참고 항목

FTP 7.0 및 FTP 7.5 서비스는 IIS 7.0용 대역 외 서비스를 제공했으며, 다음 URL에서 모듈을 다운로드하고 설치해야 했습니다.

https://www.iis.net/expand/FTP

Windows 7 및 Windows Server 2008 R2를 사용하면 FTP 7.5 서비스가 IIS 7.5의 기능으로 제공됩니다. 따라서 FTP 서비스를 더 이상 다운로드할 필요가 없습니다.

설정

웹 서버에 대한 FTP 게시를 지원하려면 FTP 서비스를 설치해야 합니다. 이렇게 하려면 다음 단계를 수행합니다.

Windows Server 2012 또는 Windows Server 2012 R2

  1. 작업 표시줄에서 서버 관리자를 클릭합니다.

  2. 서버 관리자 관리 메뉴를 클릭한 다음 역할 및 기능 추가를 클릭합니다.

  3. 역할 및 기능 추가 마법사에서 다음을 클릭합니다. 설치 유형을 선택하고 다음을 클릭합니다. 대상 서버를 선택하고 다음을 클릭합니다.

  4. 서버 역할 페이지에서 웹 서버(IIS)를 확장한 다음 FTP 서버를 선택합니다.

    참고 항목

    ASP를 지원합니다. FTP 서비스에 대한 멤버 자격 인증 또는 IIS 관리자 인증은 FTP 서비스 외에도 FTP 확장성을 선택해야 합니다.
    FT P 확장성이 강조 표시된 웹 서버 I S 및 F T P 서버의 이미지입니다. .

  5. 다음을 클릭한 다음 기능 선택 페이지에서 다음을 다시 클릭합니다.

  6. 설치 선택 확인 페이지에서 설치를 클릭합니다.

  7. Results(결과) 페이지에서 Close(닫기)를 클릭합니다.

Windows 8 또는 Windows 8.1

  1. 시작 화면에서 포인터를 왼쪽 아래 모서리로 이동하고 시작 단추를 마우스 오른쪽 단추로 클릭한 다음 제어판 클릭합니다.

  2. 제어판 프로그램 및 기능을 클릭한 다음 Windows 기능 켜기 또는 끄기를 클릭합니다.

  3. 인터넷 정보 서비스 확장한 다음 FTP 서버를 선택합니다.

    참고 항목

    ASP를 지원합니다. FTP 서비스에 대한 멤버 자격 인증 또는 IIS 관리자 인증도 FTP 확장성을 선택해야 합니다.
    인터넷 정보 서비스 및 FT P 서버 창이 확장되고 FT P 확장성이 선택된 스크린샷

  4. 확인을 클릭합니다.

  5. 닫기를 클릭합니다.

Windows Server 2008 R2

  1. 작업 표시줄에서 시작을 클릭하고 관리istrative Tools를 가리킨 다음 서버 관리자 클릭합니다.

  2. 서버 관리자 계층 구조 창에서 역할을 확장한 다음 웹 서버(IIS)를 클릭합니다.

  3. 웹 서버(IIS) 창에서 Role Services 섹션으로 스크롤한 다음 역할 서비스 추가를 클릭합니다.

  4. 역할 서비스 추가 마법사역할 서비스 선택 페이지에서 FTP 서버를 확장합니다.

  5. FTP 서비스를 선택합니다.

    참고 항목

    ASP를 지원합니다. FTP 서비스에 대한 멤버 자격 인증 또는 IIS 관리자 인증도 FTP 확장성을 선택해야 합니다.
    FT P 서버 확장 창에서 선택한 F T P 서비스 및 F T P 확장성의 이미지입니다.

  6. 다음을 클릭합니다.

  7. 설치 선택 확인 페이지에서 설치를 클릭합니다.

  8. Results(결과) 페이지에서 Close(닫기)를 클릭합니다.

Windows 7

  1. 작업 표시줄에서 시작을 클릭한 다음 제어판 클릭합니다.

  2. 제어판 프로그램 및 기능을 클릭한 다음 Windows 기능 켜기 또는 끄기를 클릭합니다.

  3. 인터넷 정보 서비스 확장한 다음 FTP 서버를 확장합니다.

  4. FTP 서비스를 선택합니다.

    참고 항목

    ASP를 지원합니다. FTP 서비스에 대한 멤버 자격 인증 또는 IIS 관리자 인증도 FTP 확장성을 선택해야 합니다.
    FT P 서버에서 선택한 F T P 확장성 및 확장된 창 인터넷 정보 서비스 스크린샷

  5. 확인을 클릭합니다.

Windows Server 2008 또는 Windows Vista

  1. 다음 URL에서 설치 패키지를 다운로드합니다.

  2. 다음 연습의 지침에 따라 FTP 서비스를 설치합니다.

방법

FTP 사이트에 대해 익명 인증을 사용하거나 사용하지 않도록 설정하는 방법

  1. IIS(open 인터넷 정보 서비스) 관리자:

    • Windows Server 2012 또는 Windows Server 2012 R2를 사용하는 경우:

      • 작업 표시줄에서 서버 관리자 클릭하고 도구를 클릭한 다음 인터넷 정보 서비스(IIS) 관리자를 클릭합니다.
    • Windows 8 또는 Windows 8.1을 사용하는 경우:

      • Windows 키를 누른 상태로 문자 X를 누른 다음 제어판 클릭합니다.
      • 관리istrative Tools를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
    • Windows Server 2008 또는 Windows Server 2008 R2를 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭하고 관리영구 도구를 가리킨 다음 IIS(인터넷 정보 서비스) 관리자를 클릭합니다.
    • Windows Vista 또는 Windows 7을 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭한 다음 제어판 클릭합니다.
      • 관리istrative Tools를 두 번 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
  2. 커넥트 창에서 서버 이름을 확장하고 사이트 노드를 확장한 다음 사이트 이름을 클릭합니다.

  3. 사이트의 창에서 FTP 인증 기능을 두 번 클릭합니다.

  4. FTP 인증 페이지에서 익명 인증을 선택합니다.

  5. 작업 창에서 [사용]을 클릭하여 익명 인증을 사용하도록 설정하거나 [사용 안 함]을 클릭하여 익명 인증을 사용하지 않도록 설정합니다.
    익명 인증을 사용할 수 없음을 표시하는 작업 창의 F T P 인증 이미지


FTP 사이트 마법사를 사용하여 익명 읽기 권한이 있는 FTP 사이트를 만드는 방법

  1. IIS(open 인터넷 정보 서비스) 관리자:

    • Windows Server 2012 또는 Windows Server 2012 R2를 사용하는 경우:

      • 작업 표시줄에서 서버 관리자 클릭하고 도구를 클릭한 다음 인터넷 정보 서비스(IIS) 관리자를 클릭합니다.
    • Windows 8 또는 Windows 8.1을 사용하는 경우:

      • Windows 키를 누른 상태로 문자 X를 누른 다음 제어판 클릭합니다.
      • 관리istrative Tools를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
    • Windows Server 2008 또는 Windows Server 2008 R2를 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭하고 관리영구 도구를 가리킨 다음 IIS(인터넷 정보 서비스) 관리자를 클릭합니다.
    • Windows Vista 또는 Windows 7을 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭한 다음 제어판 클릭합니다.
      • 관리istrative Tools를 두 번 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
  2. 커넥트 창에서 트리의 사이트 노드를 클릭합니다.

  3. 트리에서 사이트 노드를 마우스 오른쪽 단추로 클릭하고 FTP 사이트 추가를 클릭하거나 작업 창에서 FTP 사이트 추가를 클릭합니다.

  4. FTP 사이트 추가 마법사가 표시되는 경우:

    • FTP 사이트 이름 상자에 "내 새 FTP 사이트"를 입력합니다.

    • 물리적 경로 상자의 경우 다음 옵션 중 하나를 사용하여 콘텐츠 디렉터리를 지정할 수 있습니다.

      • 줄임표(...) 단추를 클릭한 다음 FTP 사이트의 콘텐츠가 포함된 폴더로 이동합니다.
      • 상자에 콘텐츠 폴더의 경로를 입력합니다. 경로를 입력하도록 선택하는 경우 경로에서 환경 변수를 사용할 수 있습니다. 예를 들어 콘텐츠 디렉터리에 "%SystemDrive%\inetpub\ftproot"를 사용할 수 있습니다.
    • 이러한 항목을 완료했으면 다음을 클릭합니다.
      FT P 사이트 이름 상자에 새 FT P 사이트를 입력한 FT P 사이트 추가 대화 상자의 이미지.

  5. FTP 사이트 추가 마법사의 두 번째 페이지에서 다음을 수행합니다.

    • IP 주소 드롭다운에서 FTP 사이트의 IP 주소를 선택하거나 "할당되지 않은 모든 항목"의 기본 선택을 수락하도록 선택합니다.

    • 포트 상자에 FTP 사이트의 TCP/IP 포트입력합니다. 기본적으로 FTP 사이트 및 클라이언트는 포트 21을 사용합니다. (참고: 암시적 FTPS를 지정하려면 포트 990을 사용해야 합니다.)

    • FTP 가상 호스트 이름을 사용하려면 가상 호스트 이름 사용 상자를 선택한 다음 가상 호스트 상자에 가상 호스트 이름을 입력합니다.

    • SSL 옵션의 경우 다음 옵션 중 하나를 선택합니다.

      • SSL 옵션을 사용하지 않도록 설정하려면 SSL 없음을 선택합니다.
      • FTP 클라이언트가 FTP 서버에 연결할 때 선택적으로 SSL을 통해 FTP를 사용하도록 허용하려면 SSL 허용을 선택합니다.
      • FTP 클라이언트가 FTP 서버에 연결할 때 항상 SSL을 통해 FTP를 사용할 수 있도록 하려면 SSL 필요를 선택합니다.
      • SSL 허용 또는 SSL 필요를 선택하는 경우 SSL 인증서 드롭다운 메뉴에서 인증서 를 선택합니다.
    • 이러한 항목을 완료했으면 다음을 클릭합니다.
      바인딩 섹션에 I P 주소 상자가 있는 바인딩 및 S S L 설정 대화 상자의 이미지입니다.

  6. 마법사의 다음 페이지에서 다음을 수행합니다.

    • 인증 설정에 대해 익명선택합니다.
    • 권한 부여 설정의 경우 액세스 허용 드롭다운에서 "익명 사용자"를 선택합니다.
    • 사용 권한에 대한 읽기 옵션을 선택합니다.
    • 이러한 항목을 완료했으면 마침을 클릭합니다.
      익명 옵션이 선택된 인증 및 권한 부여 설정의 이미지입니다.

FTP 사이트에 대한 기본 인증을 사용하거나 사용하지 않도록 설정하는 방법

  1. IIS(open 인터넷 정보 서비스) 관리자:

    • Windows Server 2012 또는 Windows Server 2012 R2를 사용하는 경우:

      • 작업 표시줄에서 서버 관리자 클릭하고 도구를 클릭한 다음 인터넷 정보 서비스(IIS) 관리자를 클릭합니다.
    • Windows 8 또는 Windows 8.1을 사용하는 경우:

      • Windows 키를 누른 상태로 문자 X를 누른 다음 제어판 클릭합니다.
      • 관리istrative Tools를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
    • Windows Server 2008 또는 Windows Server 2008 R2를 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭하고 관리영구 도구를 가리킨 다음 IIS(인터넷 정보 서비스) 관리자를 클릭합니다.
    • Windows Vista 또는 Windows 7을 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭한 다음 제어판 클릭합니다.
      • 관리istrative Tools를 두 번 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
  2. 커넥트 창에서 서버 이름을 확장하고 사이트 노드를 확장한 다음 사이트 이름을 클릭합니다.

  3. 사이트의 창에서 FTP 인증 기능을 두 번 클릭합니다.

  4. FTP 인증 페이지에서 기본 인증을 선택합니다.
    익명 인증 및 기본 인증 옵션을 보여 주는 F T P 인증의 스크린샷

  5. 작업 창에서 [사용]을 클릭하여 기본 인증을 사용하도록 설정하거나[사용 안 함]을 클릭하여 기본 인증을 사용하지 않도록 설정합니다.


FTP 사이트 마법사를 사용하여 기본 인증 및 읽기/쓰기 권한이 있는 FTP 사이트를 만드는 방법

  1. IIS(open 인터넷 정보 서비스) 관리자:

    • Windows Server 2012 또는 Windows Server 2012 R2를 사용하는 경우:

      • 작업 표시줄에서 서버 관리자 클릭하고 도구를 클릭한 다음 인터넷 정보 서비스(IIS) 관리자를 클릭합니다.
    • Windows 8 또는 Windows 8.1을 사용하는 경우:

      • Windows 키를 누른 상태로 문자 X를 누른 다음 제어판 클릭합니다.
      • 관리istrative Tools를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
    • Windows Server 2008 또는 Windows Server 2008 R2를 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭하고 관리영구 도구를 가리킨 다음 IIS(인터넷 정보 서비스) 관리자를 클릭합니다.
    • Windows Vista 또는 Windows 7을 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭한 다음 제어판 클릭합니다.
      • 관리istrative Tools를 두 번 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
  2. 커넥트 창에서 트리의 사이트 노드를 클릭합니다.

  3. 트리에서 사이트 노드를 마우스 오른쪽 단추로 클릭하고 FTP 사이트 추가를 클릭하거나 작업 창에서 FTP 사이트 추가를 클릭합니다.

  4. FTP 사이트 추가 마법사가 표시되는 경우:

    • FTP 사이트 이름 상자에 "내 새 FTP 사이트"를 입력합니다.

    • 물리적 경로 상자의 경우 다음 옵션 중 하나를 사용하여 콘텐츠 디렉터리를 지정할 수 있습니다.

      • 줄임표(...) 단추를 클릭한 다음 FTP 사이트의 콘텐츠가 포함된 폴더로 이동합니다.
      • 상자에 콘텐츠 폴더의 경로를 입력합니다. 경로를 입력하도록 선택하는 경우 경로에서 환경 변수를 사용할 수 있습니다. 예를 들어 콘텐츠 디렉터리에 "%SystemDrive%\inetpub\ftproot"를 사용할 수 있습니다.
    • 이러한 항목을 완료했으면 다음을 클릭합니다.
      FT P 사이트 이름 필드에 입력된 내 새 FT P 사이트를 표시하는 FT P 사이트 추가 마법사의 사이트 정보 이미지.

  5. FTP 사이트 추가 마법사의 두 번째 페이지에서 다음을 수행합니다.

    • IP 주소 드롭다운에서 FTP 사이트의 IP 주소를 선택하거나 "할당되지 않은 모든 항목"의 기본 선택을 수락하도록 선택합니다.

    • 포트 상자에 FTP 사이트의 TCP/IP 포트입력합니다. 기본적으로 FTP 사이트 및 클라이언트는 포트 21을 사용합니다. (참고: 암시적 FTPS를 지정하려면 포트 990을 사용해야 합니다.)

    • FTP 가상 호스트 이름을 사용하려면 가상 호스트 이름 사용 상자를 선택한 다음 가상 호스트 상자에 가상 호스트 이름을 입력합니다.

    • SSL 옵션의 경우 다음 옵션 중 하나를 선택합니다.

      • SSL 옵션을 사용하지 않도록 설정하려면 SSL 없음을 선택합니다.
      • FTP 클라이언트가 FTP 서버에 연결할 때 선택적으로 SSL을 통해 FTP를 사용하도록 허용하려면 SSL 허용을 선택합니다.
      • FTP 클라이언트가 FTP 서버에 연결할 때 항상 SSL을 통해 FTP를 사용할 수 있도록 하려면 SSL 필요를 선택합니다.
      • SSL 허용 또는 SSL 필요를 선택하는 경우 SSL 인증서 드롭다운 메뉴에서 인증서 를 선택합니다.
    • 이러한 항목을 완료했으면 다음을 클릭합니다.
      드롭다운 목록에서 선택한 I P 주소를 보여 주는 FT P 사이트 추가 마법사의 바인딩 및 S L 설정 이미지

  6. 마법사의 다음 페이지에서 다음을 수행합니다.

    • 인증 설정에 대한 기본선택합니다.
    • 권한 부여 설정의 경우 액세스 허용 드롭다운에서 "지정된 사용자"를 선택하고 드롭다운 메뉴 아래 상자에 계정 이름을 입력합니다.
    • 사용 권한 옵션에 대해 읽기쓰기선택합니다.
    • 이러한 항목을 완료했으면 마침을 클릭합니다.
      기본 옵션이 선택된 FT P 사이트 추가 마법사의 인증 및 권한 부여 설정 스크린샷

구성

요소는 <security> 사이트 수준에서 구성됩니다.

특성

없음

자식 요소

요소 설명
authentication 선택적 요소입니다.

FTP 사이트에 대한 인증 설정을 지정합니다.
commandFiltering 선택적 요소입니다.

FTP 명령 필터링에 대한 설정을 지정합니다.
customAuthorization 선택적 요소입니다.

FTP 권한 부여에 사용자 지정 공급자의 사용을 지정합니다.
dataChannelSecurity 선택적 요소입니다.

FTP 데이터 채널 보안에 대한 설정을 지정합니다.
ssl 선택적 요소입니다.

FTP 사이트에 대한 SSL 설정을 지정합니다.
sslClientCertificates 선택적 요소입니다.

FTP 사이트에 대한 SSL 클라이언트 인증서 옵션을 지정합니다.

구성 샘플

다음 샘플에서는 FTP 사이트에 대한 요소의 <ftpServer> 몇 가지 구성 설정을 보여 줍니다. 보다 구체적으로 이 예제의 설정은 <site> 다음을 하는 방법을 보여 줍니다.

  • FTP 사이트를 만들고 포트 21에서 FTP 프로토콜에 대한 바인딩을 추가합니다.
  • 인증서를 사용하여 컨트롤 및 데이터 채널 모두에서 보안 액세스를 허용하도록 FTP SSL 옵션을 구성합니다.
  • 익명 인증을 사용하지 않도록 설정하고 FTP에 대한 기본 인증을 사용하도록 설정합니다.
  • FTP SYST 명령에 대한 액세스를 거부합니다.
  • UNIX 디렉터리 목록 형식을 지정합니다.
  • 로깅 옵션을 구성합니다.
  • 사용자 지정된 환영 메시지를 지정하고 로컬 세부 오류 메시지를 사용하도록 설정합니다.
  • 사용자가 로그인 이름을 기반으로 하는 홈 디렉터리에서 시작하지만 해당 디렉터리가 있는 경우에만 시작되도록 지정합니다.
<site name="ftp.example.com" id="5">
  <application path="/">
    <virtualDirectory path="/" physicalPath="c:\inetpub\www.example.com" />
  </application>
  <bindings>
    <binding protocol="ftp" bindingInformation="*:21:" />
  </bindings>
  <ftpServer>
    <security>
      <ssl controlChannelPolicy="SslAllow"
         dataChannelPolicy="SslAllow"
         serverCertHash="57686f6120447564652c2049495320526f636b73" />
      <authentication>
        <basicAuthentication enabled="true" />
        <anonymousAuthentication enabled="false" />
      </authentication>
      <commandFiltering maxCommandLine="4096" allowUnlisted="true">
        <add command="SYST" allowed="false" />
      </commandFiltering>
    </security>
    <directoryBrowse showFlags="StyleUnix" />
    <logFile logExtFileFlags="Date, Time, ClientIP, UserName, ServerIP, Method, UriStem, FtpStatus, Win32Status, ServerPort, FtpSubStatus, Session, FullPath, Info" />
    <messages expandVariables="true"
       greetingMessage="Welcome %UserName%!"
       allowLocalDetailedErrors="true" />
    <userIsolation mode="StartInUsersDirectory" />
  </ftpServer>
</site>

예제 코드

다음 예제에서는 FTP 사이트에 대해 익명 인증을 사용하지 않도록 설정합니다.

Appcmd.exe

appcmd.exe set config -section:system.applicationHost/sites /[name='ftp.example.com'].ftpServer.security.authentication.anonymousAuthentication.enabled:"False" /commit:apphost

참고 항목

AppCmd.exe 사용하여 이러한 설정을 구성할 때 커밋 매개 변수 apphost 를 설정해야 합니다. 그러면 ApplicationHost.config 파일의 적절한 위치 섹션에 구성 설정이 커밋됩니다.

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetApplicationHostConfiguration();
         ConfigurationSection sitesSection = config.GetSection("system.applicationHost/sites");
         ConfigurationElementCollection sitesCollection = sitesSection.GetCollection();

         ConfigurationElement siteElement = FindElement(sitesCollection, "site", "name", @"ftp.example.com");
         if (siteElement == null) throw new InvalidOperationException("Element not found!");

         ConfigurationElement ftpServerElement = siteElement.GetChildElement("ftpServer");
         ConfigurationElement securityElement = ftpServerElement.GetChildElement("security");
         ConfigurationElement authenticationElement = securityElement.GetChildElement("authentication");
         ConfigurationElement anonymousAuthenticationElement = authenticationElement.GetChildElement("anonymousAuthentication");
         anonymousAuthenticationElement["enabled"] = false;

         serverManager.CommitChanges();
      }
   }

   private static ConfigurationElement FindElement(ConfigurationElementCollection collection, string elementTagName, params string[] keyValues)
   {
      foreach (ConfigurationElement element in collection)
      {
         if (String.Equals(element.ElementTagName, elementTagName, StringComparison.OrdinalIgnoreCase))
         {
            bool matches = true;
            for (int i = 0; i < keyValues.Length; i += 2)
            {
               object o = element.GetAttributeValue(keyValues[i]);
               string value = null;
               if (o != null)
               {
                  value = o.ToString();
               }
               if (!String.Equals(value, keyValues[i + 1], StringComparison.OrdinalIgnoreCase))
               {
                  matches = false;
                  break;
               }
            }
            if (matches)
            {
               return element;
            }
         }
      }
      return null;
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample
   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetApplicationHostConfiguration
      Dim sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")
      Dim sitesCollection As ConfigurationElementCollection = sitesSection.GetCollection

      Dim siteElement As ConfigurationElement = FindElement(sitesCollection, "site", "name", "ftp.example.com")
      If (siteElement Is Nothing) Then
         Throw New InvalidOperationException("Element not found!")
      End If

      Dim ftpServerElement As ConfigurationElement = siteElement.GetChildElement("ftpServer")
      Dim securityElement As ConfigurationElement = ftpServerElement.GetChildElement("security")
      Dim authenticationElement As ConfigurationElement = securityElement.GetChildElement("authentication")
      Dim anonymousAuthenticationElement As ConfigurationElement = authenticationElement.GetChildElement("anonymousAuthentication")
      anonymousAuthenticationElement("enabled") = False

      serverManager.CommitChanges()
   End Sub

   Private Function FindElement(ByVal collection As ConfigurationElementCollection, ByVal elementTagName As String, ByVal ParamArray keyValues() As String) As ConfigurationElement
      For Each element As ConfigurationElement In collection
         If String.Equals(element.ElementTagName, elementTagName, StringComparison.OrdinalIgnoreCase) Then
            Dim matches As Boolean = True
            Dim i As Integer
            For i = 0 To keyValues.Length - 1 Step 2
               Dim o As Object = element.GetAttributeValue(keyValues(i))
               Dim value As String = Nothing
               If (Not (o) Is Nothing) Then
                  value = o.ToString
               End If
               If Not String.Equals(value, keyValues((i + 1)), StringComparison.OrdinalIgnoreCase) Then
                  matches = False
                  Exit For
               End If
            Next
            If matches Then
               Return element
            End If
         End If
      Next
      Return Nothing
   End Function


End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
var sitesCollection = sitesSection.Collection;

var siteElementPos = FindElement(sitesCollection, "site", ["name", "ftp.example.com"]);
if (siteElementPos == -1) throw "Element not found!";
var siteElement = sitesCollection.Item(siteElementPos);

var ftpServerElement = siteElement.ChildElements.Item("ftpServer");
var securityElement = ftpServerElement.ChildElements.Item("security");
var authenticationElement = securityElement.ChildElements.Item("authentication");
var anonymousAuthenticationElement = authenticationElement.ChildElements.Item("anonymousAuthentication");
anonymousAuthenticationElement.Properties.Item("enabled").Value = false;

adminManager.CommitChanges();

function FindElement(collection, elementTagName, valuesToMatch) {
   for (var i = 0; i < collection.Count; i++) {
      var element = collection.Item(i);
      if (element.Name == elementTagName) {
         var matches = true;
         for (var iVal = 0; iVal < valuesToMatch.length; iVal += 2) {
            var property = element.GetPropertyByName(valuesToMatch[iVal]);
            var value = property.Value;
            if (value != null) {
               value = value.toString();
            }
            if (value != valuesToMatch[iVal + 1]) {
               matches = false;
               break;
            }
         }
         if (matches) {
            return i;
         }
      }
   }
   return -1;
}

VBScript

Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set sitesCollection = sitesSection.Collection

siteElementPos = FindElement(sitesCollection, "site", Array("name", "ftp.example.com"))
If siteElementPos = -1 Then
WScript.Echo "Element not found!"
WScript.Quit
End If
Set siteElement = sitesCollection.Item(siteElementPos)

Set ftpServerElement = siteElement.ChildElements.Item("ftpServer")
Set securityElement = ftpServerElement.ChildElements.Item("security")
Set authenticationElement = securityElement.ChildElements.Item("authentication")
Set anonymousAuthenticationElement = authenticationElement.ChildElements.Item("anonymousAuthentication")
anonymousAuthenticationElement.Properties.Item("enabled").Value = False

adminManager.CommitChanges()

Function FindElement(collection, elementTagName, valuesToMatch)
   For i = 0 To CInt(collection.Count) - 1
      Set element = collection.Item(i)
      If element.Name = elementTagName Then
         matches = True
         For iVal = 0 To UBound(valuesToMatch) Step 2
            Set property = element.GetPropertyByName(valuesToMatch(iVal))
            value = property.Value
            If Not IsNull(value) Then
               value = CStr(value)
            End If
            If Not value = CStr(valuesToMatch(iVal + 1)) Then
               matches = False
               Exit For
            End If
         Next
         If matches Then
            Exit For
         End If
      End If
   Next
   If matches Then
      FindElement = i
   Else
      FindElement = -1
   End If
End Function

다음 예제에서는 FTP 사이트에 대한 기본 인증을 사용하지 않도록 설정합니다.

Appcmd.exe

appcmd.exe set config -section:system.applicationHost/sites /[name='ftp.example.com'].ftpServer.security.authentication.basicAuthentication.enabled:"False" /commit:apphost

참고 항목

AppCmd.exe 사용하여 이러한 설정을 구성할 때 커밋 매개 변수 apphost 를 설정해야 합니다. 그러면 ApplicationHost.config 파일의 적절한 위치 섹션에 구성 설정이 커밋됩니다.

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetApplicationHostConfiguration();
         ConfigurationSection sitesSection = config.GetSection("system.applicationHost/sites");
         ConfigurationElementCollection sitesCollection = sitesSection.GetCollection();

         ConfigurationElement siteElement = FindElement(sitesCollection, "site", "name", @"ftp.example.com");
         if (siteElement == null) throw new InvalidOperationException("Element not found!");

         ConfigurationElement ftpServerElement = siteElement.GetChildElement("ftpServer");
         ConfigurationElement securityElement = ftpServerElement.GetChildElement("security");
         ConfigurationElement authenticationElement = securityElement.GetChildElement("authentication");
         ConfigurationElement basicAuthenticationElement = authenticationElement.GetChildElement("basicAuthentication");
         basicAuthenticationElement["enabled"] = false;

         serverManager.CommitChanges();
      }
   }

   private static ConfigurationElement FindElement(ConfigurationElementCollection collection, string elementTagName, params string[] keyValues)
   {
      foreach (ConfigurationElement element in collection)
      {
         if (String.Equals(element.ElementTagName, elementTagName, StringComparison.OrdinalIgnoreCase))
         {
            bool matches = true;
            for (int i = 0; i < keyValues.Length; i += 2)
            {
               object o = element.GetAttributeValue(keyValues[i]);
               string value = null;
               if (o != null)
               {
                  value = o.ToString();
               }
               if (!String.Equals(value, keyValues[i + 1], StringComparison.OrdinalIgnoreCase))
               {
                  matches = false;
                  break;
               }
            }
            if (matches)
            {
               return element;
            }
         }
      }
      return null;
   }

}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample
   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetApplicationHostConfiguration
      Dim sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")
      Dim sitesCollection As ConfigurationElementCollection = sitesSection.GetCollection

      Dim siteElement As ConfigurationElement = FindElement(sitesCollection, "site", "name", "ftp.example.com")
      If (siteElement Is Nothing) Then
         Throw New InvalidOperationException("Element not found!")
      End If

      Dim ftpServerElement As ConfigurationElement = siteElement.GetChildElement("ftpServer")
      Dim securityElement As ConfigurationElement = ftpServerElement.GetChildElement("security")
      Dim authenticationElement As ConfigurationElement = securityElement.GetChildElement("authentication")
      Dim basicAuthenticationElement As ConfigurationElement = authenticationElement.GetChildElement("basicAuthentication")
      basicAuthenticationElement("enabled") = False

      serverManager.CommitChanges()
   End Sub

   Private Function FindElement(ByVal collection As ConfigurationElementCollection, ByVal elementTagName As String, ByVal ParamArray keyValues() As String) As ConfigurationElement
      For Each element As ConfigurationElement In collection
         If String.Equals(element.ElementTagName, elementTagName, StringComparison.OrdinalIgnoreCase) Then
            Dim matches As Boolean = True
            Dim i As Integer
            For i = 0 To keyValues.Length - 1 Step 2
               Dim o As Object = element.GetAttributeValue(keyValues(i))
               Dim value As String = Nothing
               If (Not (o) Is Nothing) Then
                  value = o.ToString
               End If
               If Not String.Equals(value, keyValues((i + 1)), StringComparison.OrdinalIgnoreCase) Then
                  matches = False
                  Exit For
               End If
            Next
            If matches Then
               Return element
            End If
         End If
      Next
      Return Nothing
   End Function


End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
var sitesCollection = sitesSection.Collection;

var siteElementPos = FindElement(sitesCollection, "site", ["name", "ftp.example.com"]);
if (siteElementPos == -1) throw "Element not found!";
var siteElement = sitesCollection.Item(siteElementPos);

var ftpServerElement = siteElement.ChildElements.Item("ftpServer");
var securityElement = ftpServerElement.ChildElements.Item("security");
var authenticationElement = securityElement.ChildElements.Item("authentication");
var basicAuthenticationElement = authenticationElement.ChildElements.Item("basicAuthentication");
basicAuthenticationElement.Properties.Item("enabled").Value = false;

adminManager.CommitChanges();

function FindElement(collection, elementTagName, valuesToMatch) {
   for (var i = 0; i < collection.Count; i++) {
      var element = collection.Item(i);
      if (element.Name == elementTagName) {
         var matches = true;
         for (var iVal = 0; iVal < valuesToMatch.length; iVal += 2) {
            var property = element.GetPropertyByName(valuesToMatch[iVal]);
            var value = property.Value;
            if (value != null) {
               value = value.toString();
            }
            if (value != valuesToMatch[iVal + 1]) {
               matches = false;
               break;
            }
         }
         if (matches) {
            return i;
         }
      }
   }
   return -1;
}

VBScript

Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set sitesCollection = sitesSection.Collection

siteElementPos = FindElement(sitesCollection, "site", Array("name", "ftp.example.com"))
If siteElementPos = -1 Then
WScript.Echo "Element not found!"
WScript.Quit
End If
Set siteElement = sitesCollection.Item(siteElementPos)

Set ftpServerElement = siteElement.ChildElements.Item("ftpServer")
Set securityElement = ftpServerElement.ChildElements.Item("security")
Set authenticationElement = securityElement.ChildElements.Item("authentication")
Set basicAuthenticationElement = authenticationElement.ChildElements.Item("basicAuthentication")
basicAuthenticationElement.Properties.Item("enabled").Value = False

adminManager.CommitChanges()

Function FindElement(collection, elementTagName, valuesToMatch)
   For i = 0 To CInt(collection.Count) - 1
      Set element = collection.Item(i)
      If element.Name = elementTagName Then
         matches = True
         For iVal = 0 To UBound(valuesToMatch) Step 2
            Set property = element.GetPropertyByName(valuesToMatch(iVal))
            value = property.Value
            If Not IsNull(value) Then
               value = CStr(value)
            End If
            If Not value = CStr(valuesToMatch(iVal + 1)) Then
               matches = False
               Exit For
            End If
         Next
         If matches Then
            Exit For
         End If
      End If
   Next
   If matches Then
      FindElement = i
   Else
      FindElement = -1
   End If
End Function